proj_linpred extracts draws of the linear predictor and proj_predict draws from the predictive distribution of the projected submodel or submodels. If the projection has not been performed, the functions also perform the projection.

proj_linpred(object, xnew, ynew = NULL, offsetnew = NULL,
weightsnew = NULL, nv = NULL, transform = FALSE,
integrated = FALSE, ...)

proj_predict(object, xnew, offsetnew = NULL, weightsnew = NULL,
nv = NULL, draws = NULL, seed_samp = NULL, ...)

## Arguments

object Either an object returned by varsel, cv_varsel or init_refmodel, or alternatively any object that can be converted to a reference model. The predictor values used in the prediction. If vind is specified, then xnew should either be a dataframe containing column names that correspond to vind or a matrix with the number and order of columns corresponding to vind. If vind is unspecified, then xnew must either be a dataframe containing all the column names as in the original data or a matrix with the same columns at the same positions as in the original data. New (test) target variables. If given, then the log predictive density for the new observations is computed. Offsets for the new observations. By default a vector of zeros. Weights for the new observations. For binomial model, corresponds to the number trials per observation. For proj_linpred, this argument matters only if ynew is specified. By default a vector of ones. Number of variables in the submodel (the variable combination is taken from the variable selection information). If a vector with several values, then results for all specified model sizes are returned. Ignored if vind is specified. By default use the automatically suggested model size. Should the linear predictor be transformed using the inverse-link function? Default is FALSE. For proj_linpred only. If TRUE, the output is averaged over the parameters. Default is FALSE. For proj_linpred only. Additional argument passed to project if object is an object returned by varsel or cv_varsel. Number of draws to return from the predictive distribution of the projection. The default is 1000. For proj_predict only. An optional seed to use for drawing from the projection. For proj_predict only.

## Value

If the prediction is done for one submodel only (nv has length one or vind is specified) and ynew is unspecified, a matrix or vector of predictions (depending on the value of integrated). If ynew is specified, returns a list with elements pred (predictions) and lpd (log predictive densities). If the predictions are done for several submodel sizes, returns a list with one element for each submodel.

## Examples

### Usage with stanreg objects
fit <- stan_glm(y~x, binomial())#> Error in stan_glm(y ~ x, binomial()): could not find function "stan_glm"vs <- varsel(fit)#> Error in get_refmodel(object, ...): object 'fit' not found
# compute predictions with 4 variables at the training points
pred <- proj_linpred(vs, xnew=x, nv = 4)#> Error in nrow(xnew): object 'x' not foundpred <- proj_predict(vs, xnew=x, nv = 4)#> Error in nrow(xnew): object 'x' not found