posterior | R Documentation |

This function samples from the posterior distribution of a `BFmodel`

,
which can be obtained from a `BFBayesFactor`

object. If there is more
than one numerator in the `BFBayesFactor`

object, the `index`

argument can be passed to select one numerator.

```
posterior(model, index, data, iterations, ...)
## S4 method for signature 'BFmodel,missing,data.frame,missing'
posterior(model, index, data, iterations, ...)
## S4 method for signature 'BFBayesFactor,missing,missing,missing'
posterior(model, index, data, iterations, ...)
## S4 method for signature 'BFBayesFactor,numeric,missing,numeric'
posterior(model, index, data, iterations, ...)
## S4 method for signature 'BFBayesFactor,missing,missing,numeric'
posterior(model, index = NULL, data, iterations, ...)
## S4 method for signature 'BFlinearModel,missing,data.frame,numeric'
posterior(model, index = NULL, data, iterations, ...)
## S4 method for signature 'BFindepSample,missing,data.frame,numeric'
posterior(model, index = NULL, data, iterations, ...)
## S4 method for signature 'BFcontingencyTable,missing,data.frame,numeric'
posterior(model, index = NULL, data, iterations, ...)
## S4 method for signature 'BFoneSample,missing,data.frame,numeric'
posterior(model, index = NULL, data, iterations, ...)
## S4 method for signature 'BFmetat,missing,data.frame,numeric'
posterior(model, index = NULL, data, iterations, ...)
## S4 method for signature 'BFproportion,missing,data.frame,numeric'
posterior(model, index = NULL, data, iterations, ...)
## S4 method for signature 'BFcorrelation,missing,data.frame,numeric'
posterior(model, index = NULL, data, iterations, ...)
```

`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 |

The data argument is used internally, and will y 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.

Two useful arguments that can be passed to related methods are `thin`

and `columnFilter`

, currently implemented for methods using
`nWayAOV`

(models with more than one categorical covariate, or a mix of
categorical and continuous covariates). `thin`

, an integer, will keep
only every `thin`

iterations. The default is `thin=1`

, which keeps
all iterations. Argument `columnFilter`

is either `NULL`

(for no
filtering) or a character vector of extended regular expressions (see
regex help for details). Any column from an effect that matches one of
the filters will not be saved.

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

```
## 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)
## demonstrate column filtering by filtering out participant effects
data(puzzles)
bf = lmBF(RT ~ shape + color + shape:color + ID, data=puzzles)
chains = posterior(bf, iterations = 1000, progress = FALSE, columnFilter="^ID$")
colnames(chains) # Contains no participant effects
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.