Learn R Programming

BMIselect (version 1.0.1)

projection_posterior: Projection of Full-Posterior Draws onto a Reduced-Subset Model

Description

Given posterior draws beta1_arr (and optional intercepts alpha1_arr) from a full model fitted on D imputed datasets, compute the predictive projection of each draw onto the submodel defined by xs_vec. Returns the projected coefficients (and intercepts, if requested) plus the projected residual variance for each posterior draw.

Usage

projection_posterior(X_arr, beta1_arr, sigma1_vec, xs_vec, alpha1_arr = NULL)

Value

A list with components:

beta2_arr

Array npost * D * p of projected submodel coefficients.

alpha2_arr

(If alpha1_arr provided) matrix npost * D of projected intercepts.

sigma2_opt

Numeric vector length npost of projected residual variances.

Arguments

X_arr

A 3-D array of predictors, of dimension D * n * p.

beta1_arr

A npost * D * p array of full-model coefficient draws.

sigma1_vec

Numeric vector of length npost, full-model residual variances.

xs_vec

Logical vector of length p; TRUE indicates predictors to keep.

alpha1_arr

Optional npost * D matrix of full_model intercept draws. If NULL (the default), the projection omits an intercept term.

Examples

Run this code
D <- 3; n <- 50; p <- 5; npost <- 100
X_arr      <- array(rnorm(D*n*p), c(D, n, p))
beta1_arr  <- array(rnorm(npost*D*p), c(npost, D, p))
sigma1_vec <- runif(npost, 0.5, 2)
xs_vec     <- c(TRUE, FALSE, TRUE, FALSE, TRUE)
# Without intercept
proj <- projection_posterior(X_arr, beta1_arr, sigma1_vec, xs_vec)
str(proj)
# With intercept draws
alpha1_arr <- matrix(rnorm(npost*D), nrow = npost, ncol = D)
proj2 <- projection_posterior(X_arr, beta1_arr, sigma1_vec, xs_vec, alpha1_arr)
str(proj2)

Run the code above in your browser using DataLab