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, ...)
The predictor values used in the prediction. If
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
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
Should the linear predictor be transformed using the
inverse-link function? Default is
Number of draws to return from the predictive distribution of
the projection. The default is 1000.
An optional seed to use for drawing from the projection.
If the prediction is done for one submodel only (
nv has length one
vind is specified) and ynew is unspecified, a matrix or vector of
predictions (depending on the value of
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.
### 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