linearReg.R2stat: Use R^2 statistic to compute Bayes factor for regression...

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

Description

Using the classical R^2 test statistic for (linear) regression designs, this function computes the corresponding Bayes factor test.

Usage

1
  linearReg.R2stat(N, p, R2, rscale = 1)

Arguments

N

number of observations

p

number of predictors in model, excluding intercept

R2

proportion of variance accounted for by the predictors, excluding intercept

rscale

numeric prior scale

Details

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 regressionBF, and the references therein.

The Bayes factor is computed via Gaussian quadrature.

Value

a vector of length 2 containing the computed log(e) Bayes factor (against the intercept-only null), along with a proportional error estimate on the Bayes factor.

Author(s)

Richard D. Morey (richarddmorey@gmail.com) and Jeffrey N. Rouder (rouderj@missouri.edu)

References

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

See Also

integrate, lm; see lmBF for the intended interface to this function, using the full data set.

Examples

 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 almost 80,000;
## the data strongly favor hypothesis that
## the slope is not 0.
result = linearReg.R2stat(30,1,0.6813)
exp(result[['bf']])

Example output

Loading required package: coda
Loading required package: Matrix
************
Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).

Type BFManual() to open the manual.
************

Call:
lm(formula = rating ~ complaints, data = attitude)

Residuals:
     Min       1Q   Median       3Q      Max 
-12.8799  -5.9905   0.1783   6.2978   9.6294 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 14.37632    6.61999   2.172   0.0385 *  
complaints   0.75461    0.09753   7.737 1.99e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 6.993 on 28 degrees of freedom
Multiple R-squared:  0.6813,	Adjusted R-squared:  0.6699 
F-statistic: 59.86 on 1 and 28 DF,  p-value: 1.988e-08

[1] 417696

BayesFactor documentation built on May 2, 2019, 5:54 p.m.