Perform the projection predictive variable selection for generalized linear models using generic reference models.

varsel(object, d_test = NULL, method = NULL, ns = NULL, nc = NULL,
  nspred = NULL, ncpred = NULL, relax = NULL, nv_max = NULL,
  intercept = NULL, penalty = NULL, verbose = F,
  lambda_min_ratio = 1e-05, nlambda = 150, thresh = 1e-06,
  regul = 1e-04, ...)

Arguments

object

Either a refmodel-type object created by get_refmodel or init_refmodel, or an object which can be converted to a reference model using get_refmodel.

d_test

A test dataset, which is used to evaluate model performance. If not provided, training data is used. Currently this argument is for internal use only.

method

The method used in the variable selection. Possible options are 'L1' for L1-search and 'forward' for forward selection. Default is 'forward' if the number of variables in the full data is at most 20, and 'L1' otherwise.

ns

Number of posterior draws used in the variable selection. Cannot be larger than the number of draws in the reference model. Ignored if nc is set.

nc

Number of clusters to use in the clustered projection. Overrides the ns argument. Defaults to 1.

nspred

Number of samples used for prediction (after selection). Ignored if ncpred is given.

ncpred

Number of clusters used for prediction (after selection). Default is 5.

relax

If TRUE, then the projected coefficients after L1-selection are computed without any penalization (or using only the regularization determined by regul). If FALSE, then the coefficients are the solution from the L1-penalized projection. This option is relevant only if method='L1'. Default is TRUE for genuine reference models and FALSE if object is datafit (see init_refmodel).

nv_max

Maximum number of varibles until which the selection is continued. Defaults to min(20, D, floor(0.4*n)) where n is the number of observations and D the number of variables.

intercept

Whether to use intercept in the submodels. Defaults to TRUE.

penalty

Vector determining the relative penalties or costs for the variables. Zero means that those variables have no cost and will therefore be selected first, whereas Inf means that those variables will never be selected. Currently works only if method == 'L1'. By default 1 for each variable.

verbose

If TRUE, may print out some information during the selection. Defaults to FALSE.

lambda_min_ratio

Ratio between the smallest and largest lambda in the L1-penalized search. This parameter essentially determines how long the search is carried out, i.e., how large submodels are explored. No need to change the default value unless the program gives a warning about this.

nlambda

Number of values in the lambda grid for L1-penalized search. No need to change unless the program gives a warning about this.

thresh

Convergence threshold when computing L1-path. Usually no need to change this.

regul

Amount of regularization in the projection. Usually there is no need for regularization, but sometimes for some models the projection can be ill-behaved and we need to add some regularization to avoid numerical problems.

...

Additional arguments to be passed to the get_refmodel-function.

Value

An object of type vsel that contains information about the feature selection. The fields are not meant to be accessed directly by the user but instead via the helper functions (see the vignettes or type ?projpred to see the main functions in the package.)

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
#> Error in "vsel" %in% class(object): object 'vs' not found