posterior_calc: Make posterior cacluations

Description Usage Arguments Value

View source: R/posterior_calc.R

Description

A generic and some methods for creating posterior calculations. The intended use is to prepare data for use with bayesplot ppc plots. The default method works for any object for which posterior() can create a data frame of posterior samples.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
posterior_calc(object, ...)

## Default S3 method:
posterior_calc(
  object,
  formula,
  data = NULL,
  draws = NULL,
  data.frame = FALSE,
  ...
)

## S3 method for class 'data.frame'
posterior_calc(
  object,
  formula,
  data = NULL,
  draws = NULL,
  data.frame = FALSE,
  ...
)

Arguments

object

An object from which posterior calculations are made.

...

Additional arguments, currently ignored.

formula

A formula describing the quantity to be calculated. The rhs of the formula is evaluated using one posterior sample of the parameters and data. The lhs, if it exists, is used to name the resulting column when data.frame = TRUE.

data

Additional data involved in the computation. This may be the original data used to fit the model or counter-factual data.

draws

The number of draws to make from the posterior distribution. Sampling is with replacement if draws is larger than the number of posterior samples in object.

data.frame

A logical indicating whtehr the results should be returned as a data frame (TRUE) or a matrix (FALSE).

Value

A matrix with draws rows or data frame with three columns.


rpruim/CalvinBayes documentation built on April 12, 2021, 1:49 p.m.