projection_posterior {BMIselect} | R Documentation |
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)
Arguments
X_arr |
A 3-D array of predictors, of dimension |
beta1_arr |
A |
sigma1_vec |
Numeric vector of length |
xs_vec |
Logical vector of length |
alpha1_arr |
Optional |
Value
A list with components:
beta2_arr
Array
npost * D * p
of projected submodel coefficients.alpha2_arr
(If
alpha1_arr
provided) matrixnpost * D
of projected intercepts.sigma2_opt
Numeric vector length
npost
of projected residual variances.
Examples
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)