Learn R Programming

BMIselect (version 1.0.1)

projection_mean: Projecting Posterior Means of Full-Model Coefficients onto a Reduced Subset Model

Description

Given posterior means of beta1_mat (and optional intercepts alpha1_vec) from a full model fitted on D imputed datasets, compute the predictive projection onto the submodel defined by xs_vec. Returns the projected coefficients (and intercepts, if requested).

Usage

projection_mean(X_arr, beta1_mat, xs_vec, sigma2, alpha1_vec = NULL)

Value

A list with components:

beta2_mat

A D * p matrix of projected submodel coefficients.

alpha2_vec

(If alpha1_vec provided) numeric vector length D of projected intercepts.

Arguments

X_arr

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

beta1_mat

A D * p matrix of full-model coefficients, one row per imputation.

xs_vec

Logical vector of length p; TRUE for predictors to keep in the submodel.

sigma2

Numeric scalar; the residual variance from the full model (pooled across imputations).

alpha1_vec

Optional numeric vector of length D; full-model intercepts per imputation. If NULL (the default), the projection omits an intercept term.

Examples

Run this code
# Simulate a single imputation with n=50, p=5:
D <- 3; n <- 50; p <- 5
X_arr <- array(rnorm(D * n * p), c(D, n, p))
beta1_mat <- matrix(rnorm(D * p), nrow = D)
# Suppose full-model sigma2 pooled is 1.2
sigma2 <- 1.2
# Project onto predictors 1 and 4 only:
xs_vec <- c(TRUE, FALSE, FALSE, TRUE, FALSE)
proj <- projection_mean(X_arr, beta1_mat, xs_vec, sigma2)
str(proj)

# With intercept:
alpha1_vec <- rnorm(D)
proj2 <- projection_mean(X_arr, beta1_mat, xs_vec, sigma2, alpha1_vec)
str(proj2)

Run the code above in your browser using DataLab