Description Usage Arguments Details Value Author(s) References See Also Examples

This function simultaneously computes Bayes factors for groups of models in regression designs

1 2 3 4 5 6 7 8 9 | ```
regressionBF(
formula,
data,
whichModels = "all",
progress = getOption("BFprogress", interactive()),
rscaleCont = "medium",
callback = function(...) as.integer(0),
noSample = FALSE
)
``` |

`formula` |
a formula containing all covariates to include in the analysis (see Examples) |

`data` |
a data frame containing data for all factors in the formula |

`whichModels` |
which set of models to compare; see Details |

`progress` |
if |

`rscaleCont` |
prior scale on all standardized slopes |

`callback` |
callback function for third-party interfaces |

`noSample` |
if |

`regressionBF`

computes Bayes factors to test the hypothesis that
slopes are 0 against the alternative that all slopes are nonzero.

The vector of observations *y* is assumed to be distributed as

*y ~
Normal(α 1 + Xβ, σ^2 I).*

The joint prior on
*α,σ^2* is proportional to *1/σ^2*, the prior on
*β* is

*β ~ Normal(0, N g σ^2(X'X)^{-1}).*

where
*g ~ InverseGamma(1/2,r/2)*. See Liang et al. (2008) section 3 for
details.

Possible values for `whichModels`

are 'all', 'top', and 'bottom', where
'all' computes Bayes factors for all models, 'top' computes the Bayes
factors for models that have one covariate missing from the full model, and
'bottom' computes the Bayes factors for all models containing a single
covariate. Caution should be used when interpreting the results; when the
results of 'top' testing is interpreted as a test of each covariate, the
test is conditional on all other covariates being in the model (and likewise
'bottom' testing is conditional on no other covariates being in the model).

An option is included to prevent analyzing too many models at once:
`options('BFMaxModels')`

, which defaults to 50,000, is the maximum
number of models that 'regressionBF' will analyze at once. This can be
increased by increasing the option value.

For the `rscaleCont`

argument, several named values are recongized:
"medium", "wide", and "ultrawide", which correspond *r* scales of
*sqrt(2)/4*, 1/2, and *sqrt(2)/2*,
respectively. These values were chosen to yield consistent Bayes factors
with `anovaBF`

.

An object of class `BFBayesFactor`

, containing the computed
model comparisons

Richard D. Morey (richarddmorey@gmail.com)

Liang, F. and Paulo, R. and Molina, G. and Clyde, M. A. and Berger, J. O. (2008). Mixtures of g-priors for Bayesian Variable Selection. Journal of the American Statistical Association, 103, pp. 410-423

Rouder, J. N. and Morey, R. D. (in press). Bayesian testing in regression. Multivariate Behavioral Research.

Zellner, A. and Siow, A., (1980) Posterior Odds Ratios for Selected Regression Hypotheses. In Bayesian Statistics: Proceedings of the First Interanational Meeting held in Valencia (Spain). Bernardo, J. M., Lindley, D. V., and Smith A. F. M. (eds), pp. 585-603. University of Valencia.

`lmBF`

, for testing specific models, and
`anovaBF`

for the function similar to `regressionBF`

for
ANOVA models.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ```
## See help(attitude) for details about the data set
data(attitude)
## Classical regression
summary(fm1 <- lm(rating ~ ., data = attitude))
## Compute Bayes factors for all regression models
output = regressionBF(rating ~ ., data = attitude, progress=FALSE)
head(output)
## Best model is 'complaints' only
## Compute all Bayes factors against the full model, and
## look again at best models
head(output / output[63])
``` |

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.