Learn R Programming

BayesFactor (version 0.9.0)

posterior: Sample from the posterior distribution of one of several models.

Description

This function samples from the posterior distribution of a BFmodel, which can be obtained from a BFBayesFactor object. If is are more than one numerator in the BFBayesFactor object, the index argument can be passed to select one numerator.

Arguments

model
or set of models from which to sample
index
the index within the set of models giving the desired model
data
the data to be conditioned on
iterations
the number of iterations to sample
...
arguments passed to and from related methods

Value

  • Returns an object containing samples from the posterior distribution of the specified model

Details

The data argument is used internally, and will typically not be needed by end-users.

Note that if there are fixed effects in the model, the reduced parameterzation used internally (see help for anovaBF) is unreduced. For a factor with two levels, the chain will contain two effect estimates that sum to 0.

Examples

Run this code
## Sample from the posteriors for two models
data(sleep)

bf = lmBF(extra ~ group + ID, data = sleep, whichRandom="ID", progress=FALSE)

## sample from the posterior of the numerator model
## data argument not needed - it is included in the Bayes factor object
chains = posterior(bf, iterations = 1000, progress = FALSE)

plot(chains)

Run the code above in your browser using DataLab