Extract draws of the linear predictor and draw from the predictive distribution of the projected submodel
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, newdata, offsetnew = NULL, weightsnew = NULL, nterms = NULL, transform = FALSE, integrated = FALSE, seed = NULL, ... ) proj_predict( object, newdata, offsetnew = NULL, weightsnew = NULL, nterms = NULL, ndraws = 1000, seed = NULL, ... )
object | 
 Either an object returned by varsel, cv_varsel or init_refmodel, or alternatively any object that can be converted to a reference model.  | 
newdata | 
 The predictor values used in the prediction. If
  | 
offsetnew | 
 Offsets for the new observations. By default a vector of zeros. By default we take the weights from newdata as in the original model. Either NULL or right hand side formula.  | 
weightsnew | 
 Weights for the new observations. For binomial model,
corresponds to the number trials per observation. For   | 
nterms | 
 Number of terms 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
  | 
transform | 
 Should the linear predictor be transformed using the
inverse-link function? Default is   | 
integrated | 
 If   | 
seed | 
 An optional seed to use for drawing from the projection. For
  | 
... | 
 Additional argument passed to project if   | 
ndraws | 
 Number of draws to return from the predictive distribution of
the projection. The default is 1000. For   | 
If the prediction is done for one submodel only (nterms has
length one or solution_terms is specified) and newdata is
unspecified, a matrix or vector of predictions (depending on the value of
integrated). If newdata 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.
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)
  
  # compute predictions with 4 variables at the training points
  pred <- proj_linpred(vs, newdata = data, nv = 4)
  pred <- proj_predict(vs, newdata = data, nv = 4)
}Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.