Learn R Programming

mombf (version 2.2.3)

rnlp: Posterior sampling for Non-Local Priors

Description

Gibbs sampler for linear and Cox proportional hazards model under product non-local priors and Zellner's prior. Both sampling conditional on a model and Bayesian model averaging are implemented (see Details).

If x and y not specified samples from non-local priors/posteriors with density proportional to d(theta) N(theta; m, V) are produced, where d(theta) is the non-local penalty term.

Usage

rnlp(y, x, m, V, msfit, priorCoef, priorVar, niter=10^3,
burnin=round(niter/10), thinning=1, pp='norm')

Arguments

y

Vector with observed responses. When class(y)=='Surv' sampling is based on the Cox partial likelihood, else a linear model is assumed.

x

Design matrix with all potential predictors

m

Mean for the Normal kernel

V

Covariance for the Normal kernel

msfit

Object of class msfit returned by modelSelection. If specified Bayesian model averaging posterior samples are returned, according to posterior model probabilities in msfit, and then arguments y, x, m, V, priorCoef, priorVar are all ignored. If msfit is missing then posterior samples under the full model y ~ x are returned

priorCoef

Prior distribution for the coefficients. Ignored if msfit is supplied. Must be object of class msPriorSpec, e.g. created by momprior, emomprior, imomprior, zellnerprior

priorVar

Prior on residual variance. Ignored if msfit supplied. Must be object of class msPriorSpec, e.g. created with igprior

niter

Number of MCMC iterations

burnin

Number of burn-in MCMC iterations. Defaults to .1*niter. Set to 0 for no burn-in

thinning

MCMC thinning factor, i.e. only one out of each thinning iterations are reported. Defaults to no thinning

pp

When msfit is provided this is the method to compute posterior model probabilities, which determine the sampled models. Can be 'norm' or 'exact', see postProb for details.

Value

Matrix with posterior samples

Details

The algorithm is implemented for product MOM (pMOM), product iMOM (piMOM) and product eMOM (peMOM) priors. The algorithm combines an orthogonalization that provides low serial correlation with a latent truncation representation that allows fast sampling.

When y and x are specified sampling is for the linear regression posterior. When argument msfit is left missing, posterior sampling is for the full model regressing y on all covariates in x. When msfit is specified each model is drawn with probability given by postProb(msfit). In this case, a Bayesian Model Averaging estimate of the regression coefficients can be obtained by applying colMeans to the rnlp ouput matrix.

When y and x are left missing, sampling is from a density proportional to d(theta) N(theta; m,V), where d(theta) is the non-local penalty (e.g. d(theta)=prod(theta^(2r)) for the pMOM prior).

References

D. Rossell and D. Telesca. Non-local priors for high-dimensional estimation, 2014. http://arxiv.org/pdf/1402.5107v2.pdf

See Also

modelSelection to perform model selection and compute posterior model probabilities. For more details on prior specification see msPriorSpec-class.

Examples

Run this code
# NOT RUN {
#Simulate data
x <- matrix(rnorm(100*3),nrow=100,ncol=3)
theta <- matrix(c(1,1,0),ncol=1)
y <- x %*% theta + rnorm(100)
fit1 <- modelSelection(y=y, x=x, center=FALSE, scale=FALSE)

th <- rnlp(msfit=fit1, niter=100)
colMeans(th)
# }

Run the code above in your browser using DataLab