Using the classical R^2 test statistic for (linear) regression designs, this function computes the corresponding Bayes factor test.
number of observations
number of predictors in model, excluding intercept
proportion of variance accounted for by the predictors, excluding intercept
numeric prior scale
This function can be used to compute the Bayes factor corresponding to a
multiple regression, using the classical R^2 (coefficient of determination)
statistic. It can be used when you don't have access to the full data set
for analysis by
lmBF, but you do have the test statistic.
For details about the model, see the help for
and the references therein.
The Bayes factor is computed via Gaussian quadrature.
TRUE, returns the Bayes factor (against the
intercept-only null). If
FALSE, the function returns a
vector of length 3 containing the computed log(e) Bayes factor,
along with a proportional error estimate on the Bayes factor and the method used to compute it.
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, Multivariate Behavioral Research). Bayesian testing in regression.
Perception and Cognition Lab (University of Missouri): Bayes factor calculators. http://pcl.missouri.edu/bayesfactor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
## Use attitude data set data(attitude) ## Scatterplot lm1 = lm(rating~complaints,data=attitude) plot(attitude$complaints,attitude$rating) abline(lm1) ## Traditional analysis ## p value is highly significant summary(lm1) ## Bayes factor ## The Bayes factor is over 400,000; ## the data strongly favor hypothesis that ## the slope is not 0. result = linearReg.R2stat(30,1,0.6813) exp(result[['bf']])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.