Description Usage Arguments Value Author(s) References See Also Examples
Fits the Bayesian penalized credible regions method from the posterior mean and covariance of a Bayesian model. The function performs variable selection (Bondell and Reich 2012) and confounder selection (Wilson and Reich 2014). The default is variable selection and confounder selection is only performed if confounder weights are provided.
1 |
beta |
p-vector of posterior means from the fitting of the full regression model. For confounder selection this is the outcome model. |
beta_cov |
Posterior covariance matrix corresponding to beta. |
joint |
Indicator if joint credible regions approach should be used. If joint=FALSE the marginal approach of Bondell and Reich (2012) will be used. The marginal approach is only available for variable selection, not confounder selection. |
force |
A vector of columns corresponding to variables that are forced to be included in the model. For example, this may include an intercept. For confounder selection the exposure(s) of interest should be forced into the model. |
confounder.weights |
The posterior mean from the exposure model for confounder selection. For a single exposure this is a p-vector with exposure model regression coefficients in the same order as in beta. For multiple exposures this is a matrix with p rows and a column for each exposure. The locations corresponding to exposure(s) in beta can be set to any numeric value; they are not used. For variable selection this is omitted. |
max.steps |
Maximum number of steps to be performed in the LARS algorithm (Hastie and Efron 2013). |
joint.path |
A complete solution path for the joint credible regions approach. Each row is a model in the solution path with a 1 indicating a variable is included and a 0 indicating it is not included. |
marginal.path |
A complete solution path for the marginal credible regions approach. The p-vector denotes the step at which each covariate is included in the model. |
order.path |
The action returned from lars that shows when each covariate is added to the model. |
order.marg |
The the covariate added at each step. |
joint |
Returns a vector indicating which variables are forced into the model. |
force |
Returns the logical joint. |
Ander Wilson, Howard D. Bondell, and Brian J. Reich
Bondell, H. D. and Reich, B. J. (2012). Consistent high-dimensional Bayesian variable selection via penalized credible regions. J. Am. Statist. Assoc. 107, 1610-1624.
Trevor Hastie and Brad Efron (2013). lars: Least Angle Regression, Lasso and Forward Stagewise. R package version 1.2. http://CRAN.R-project.org/package=lars
Wilson A., Reich B. J. (2014). Confounder selection via penalized credible regions. Biometrics 70: 852-861.
BayesPen.lm
, BayesPen.lm.confounders
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ######################
#Variable Selection
set.seed(1234)
dat <- SimExample(500,model="BR1")
X <- dat$X
y <- dat$y
#fit the full model assuming flat priors on beta
fit1 <- lm(y~X-1)
betahat <- coef(fit1)
cov <- vcov(fit1)
#find solution path
fit.BayesPen <- BayesPen(beta=betahat, beta_cov=cov)
#refit the model
refit <- BayesPen.refit(y,X,fit.BayesPen)
#plot it
BayesPen.plot(refit)
######################
#Confounder Selection
set.seed(1234)
dat <- SimExample(500,model="WPD2")
X <- dat$X
U <- dat$U
W <- cbind(X,U)
y <- dat$y
#fit the full outcome model assuming flat priors on beta
fit1 <- lm(y~W-1)
betahat <- coef(fit1)
cov <- vcov(fit1)
#fit the full exposure model assuming flat priors on beta
fit2 <- lm(X~U-1)
gammahat <- coef(fit2)
#find solution path
fit.BayesPen <- BayesPen(beta=betahat, beta_cov=cov, confounder.weights=c(0,gammahat), force=1)
#refit the model
refit <- BayesPen.refit(y,W,fit.BayesPen)
#plot it
BayesPen.plot(refit)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.