BayesFactor (version 0.9.12-4.2)

compare: Compare two models, with respect to some data

Description

This method is used primarily in the backend, and will only rarely be called by the end user. But see the examples below for a demonstration.

Usage

compare(numerator, denominator, data, ...)

Arguments

numerator

first model

denominator

second model (if omitted, compare to predefined null)

data

data for the comparison

...

arguments passed to and from related methods

Value

The compare function will return a model comparison object, typically a Bayes factor

Examples

Run this code
# NOT RUN {
## Sample from the posteriors for two models
data(puzzles)

## Main effects model; result is a BFmcmc object, inheriting
## mcmc from the coda package
mod1 = lmBF(RT ~ shape + color + ID, data = puzzles, whichRandom = "ID",
   progress = FALSE, posterior = TRUE, iterations = 1000)

plot(mod1)

## Full model
mod2 = lmBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID",
   progress = FALSE, posterior = TRUE, iterations = 1000)

## Each BFmcmc object contains the model used to generate it, so we
## can compare them (data is not needed, it is contained in the objects):

compare(mod1, mod2)
# }

Run the code above in your browser using DataLab