help subset

Title

subset- Implementing covariates best and stepwise subset selection

Syntax

subset
outcome
[varlist]
[if] [in],
model(modeltype)
rversion(R_version)
[nvmax(number)
index_values(filename)
matrix_results(filename)
optimal_vars(filename)]

Description

subset is a Stata wrapper for the R function "regsubsets()", providing "best",
"backward", and "forward" stepwise subset covariates selection, a Machine Learning approach to select the optimal number of features (covariates)
in a supervised linear learning approach (i.e. a linear regression model) with many covariates.
The "forward" model can be also used when p (the number of covariates) is
larger than N (the sample size). This method provides both the optimal
subset of covariates for each specific size of the model
(i.e., size=1 covariates, size=2 covariates, etc.),
and the overall optimal size. The latter one is found
using three criteria as validation approaches: Adjusted R2, CP, and BIC.

Options

General options

model(modeltype) specifies the model
to be estimated. It is always required to specify one model.

rversion(R_version) specifies the R version intalled in the operating system. A typical value is: "3.6.0".

nvmax(number) specifies the maximum order of best set of variables to show as result.

index_values(filename) specifies the name of the Stata .dta file containing the values of the AdjR2 (adjusted R2), CP, and BIC used for finding the final optimal number of covariates.

matrix_results(filename) specifies the name of the Stata .dta file containing the matrix of results, i.e. the optimal number of covariates for each model number of covariates.

optimal_vars(filename) specifies the name of the Stata .dta file containing the name of the optimal covariates at each model number of covariates.

modeltype_options

Model
best_subset Best subset selection

backward Backward stepwise selection

forward Forward stepwise selection

Remarks

--> Before running this program, remember to have the most recent up-to-date version installed.

Examples

. subset y w x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 , model(backward) rversion("3.6.0") nvmax(6) index_values("myindex") matrix_results("myresults")

Reference

Gareth, J., Witten, Hastie, D.T., Tibshirani. 2013. An Introduction to Statistical Learning : with Applications in R. New York, Springer.

Author

Giovanni Cerulli

IRCrES-CNR

Research Institute for Sustainable Economic Growth, National Research Council of Italy

E-mail: giovanni.cerulli@ircres.cnr.it

Also see

Online: srtree, sctree