momknown: Bayes factors for moment and inverse moment priors

View source: R/mombf.R

momknownR Documentation

Bayes factors for moment and inverse moment priors

Description

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.

Usage

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)

Arguments

theta1hat

Vector with regression coefficients estimates.

V1

Matrix proportional to the covariance of theta1hat. For linear models, the covariance is sigma^2*V1.

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 dmom and dimom for details.

theta0

Null value for the regression coefficients. Defaults to 0.

sigma

Dispersion parameter is sigma^2.

logbf

If logbf==TRUE the natural logarithm of the Bayes factor is returned.

nu

Prior parameter for the inverse moment prior. See dimom for details. Defaults to nu=1, which Cauchy-like tails.

method

Numerical integration method (only used by imomknown and imomunknown). Set method=='adapt' in imomknown to integrate using adaptive quadrature of functions as implemented in the function integrate. In imomunknown the integral is evaluated as in imomknown at a series of nquant quantiles of the posterior for sigma, and then averaged as described in Johnson (1992). Set method=='MC' to use Monte Carlo integration.

nquant

Number of quantiles at which to evaluate the integral for known sigma.

B

Number of Monte Carlo samples to estimate the inverse moment Bayes factor. Ignored if method!='MC'.

Details

See dmom and dimom for details on the moment and inverse moment priors. The Zellner-Siow g-prior is given by dmvnorm(theta,theta0,n*g*V1).

Value

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.

Author(s)

David Rossell

References

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. 852-860.

See Also

mombf and imombf for a simpler interface to compute Bayes factors in linear regression

Examples

#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


mombf documentation built on Sept. 28, 2023, 5:06 p.m.