Projection to submodels
Perform projection onto submodels of selected sizes or a specified feature combination.
project( object, nterms = NULL, solution_terms = NULL, cv_search = TRUE, ndraws = 400, nclusters = NULL, intercept = NULL, seed = NULL, regul = 1e-04, ... )
object |
Either a |
nterms |
Number of terms in the submodel (the variable combination is
taken from the |
solution_terms |
Variable indices onto which the projection is done. If
specified, |
cv_search |
If TRUE, then the projected coefficients after L1-selection
are computed without any penalization (or using only the regularization
determined by |
ndraws |
Number of posterior draws to be projected. Ignored if
|
nclusters |
Number of clusters in the clustered projection. |
intercept |
Whether to use intercept. Default is |
seed |
A seed used in the clustering (if |
regul |
Ridgre regularization constant to fit the projections. |
... |
Currently ignored. |
A list of submodels (or a single submodel if projection was performed onto a single variable combination), each of which contains the following elements:
kl
The KL divergence from the reference model to the submodel.
weights
Weights for each draw of the projected model.
dis
Draws from the projected dispersion parameter.
alpha
Draws from the projected intercept.
beta
Draws from the projected weight vector.
solution_terms
The order in which the variables were added to the submodel.
intercept
Whether or not the model contains an intercept.
family
A modified family
-object.
if (requireNamespace("rstanarm", quietly = TRUE)) { ### Usage with stanreg objects n <- 30 d <- 5 x <- matrix(rnorm(n * d), nrow = n) y <- x[, 1] + 0.5 * rnorm(n) data <- data.frame(x, y) fit <- rstanarm::stan_glm(y ~ X1 + X2 + X3 + X4 + X5, gaussian(), data = data, chains = 2, iter = 500) vs <- varsel(fit) # project onto the best model with 4 variables proj4 <- project(vs, nterms = 4) # project onto an arbitrary variable combination (variable indices 1, 3 and 5) proj <- project(fit, solution_terms = c(1, 3, 5)) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.