momknown
and momunknown
compute moment Bayes
factors for linear models when sigma^2
is known and unknown,
respectively. The functions can also be used to compute approximate
Bayes factors for generalized linear models and other settings.
imomknown
, imomunknown
compute inverse
moment Bayes factors. zbfknown
,
zbfunknown
compute Bayes factors based on the
ZellnerSiow gprior.
1 2 3 4 5 6 7 8 9 10  momknown(theta1hat, V1, n, g = 1, theta0, sigma, logbf = FALSE)
momunknown(theta1hat, V1, n, nuisance.theta, g = 1, theta0, ssr, logbf =
FALSE)
imomknown(theta1hat, V1, n, nuisance.theta, g = 1, nu = 1, theta0,
sigma, method='adapt', B=10^5)
imomunknown(theta1hat, V1, n, nuisance.theta, g = 1, nu = 1, theta0,
ssr, method='adapt', nquant = 100, B = 10^5)
zbfknown(theta1hat, V1, n, g = 1, theta0, sigma, logbf = FALSE)
zbfunknown(theta1hat, V1, n, nuisance.theta, g = 1, theta0, ssr, logbf =
FALSE)

theta1hat 
Vector with regression coefficients estimates. 
V1 
Matrix proportional to the covariance of

n 
Sample size. 
nuisance.theta 
Number of nuisance regression coefficients, i.e. coefficients that we do not wish to test for. 
ssr 
Sum of squared residuals from a linear model call. 
g 
Prior parameter. See 
theta0 
Null value for the regression coefficients. Defaults to 0. 
sigma 
Dispersion parameter is 
logbf 
If 
nu 
Prior parameter for the inverse moment prior. See

method 
Numerical integration method (only used by

nquant 
Number of quantiles at which to evaluate the integral
for known 
B 
Number of Monte Carlo samples to estimate the inverse moment
Bayes factor. Ignored if 
See dmom
and dimom
for details on the moment and inverse
moment priors.
The ZellnerSiow gprior is given by dmvnorm(theta,theta0,n*g*V1).
momknown
and momunknown
return the moment Bayes factor to compare the model where
theta!=theta0
with the null model where theta==theta0
. Large values favor the
alternative model; small values favor the null.
imomknown
and imomunknown
return
inverse moment Bayes factors.
zbfknown
and zbfunknown
return Bayes factors based on the ZellnerSiow gprior.
David Rossell
See http://rosselldavid.googlepages.com for technical reports.
For details on the quantile integration, see Johnson, V.E. A Technique for Estimating Marginal Posterior Densities in Hierarchical Models Using Mixtures of Conditional Densities. Journal of the American Statistical Association, Vol. 87, No. 419. (Sep., 1992), pp. 852860.
mombf
and
imombf
for a simpler interface to compute Bayes
factors in linear regression. mode2g
for prior elicitation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  #simulate data from probit regression
set.seed(4*2*2008)
n < 50; theta < c(log(2),0)
x < matrix(NA,nrow=n,ncol=2)
x[,1] < rnorm(n,0,1); x[,2] < rnorm(n,.5*x[,1],1)
p < pnorm(x[,1]*theta[1]+x[,2]+theta[2])
y < rbinom(n,1,p)
#fit model
glm1 < glm(y~x[,1]+x[,2],family=binomial(link = "probit"))
thetahat < coef(glm1)
V < summary(glm1)$cov.scaled
#compute Bayes factors to test whether x[,1] can be dropped from the model
g < .5
bfmom.1 < momknown(thetahat[2],V[2,2],n=n,g=g,sigma=1)
bfimom.1 < imomknown(thetahat[2],V[2,2],n=n,nuisance.theta=2,g=g,sigma=1)
bfmom.1
bfimom.1

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.