*! version 1.3.6 26jun2025

Title

allsets -- Find the best subset for Linear, Logistic,
Cox proportional hazards and Competing-risk (Fine-Gray) regression

Syntax

Syntax for Linear or Logistic regression

allsets depvar indepvars [if] [in] [weight], linear | logistic [options]

Syntax for Cox proportional hazards regression

allsets indepvars [if] [in], cox [options]

Syntax for Competing-risk (Fine and Gray method) regression

allsets indepvars [if] [in], finegray
compete(crvar[==numlist])
[options]

linear Linear regression; see regress

logistic Logistic regression; see logit

cox Cox regression*; see stcox

finegray Competing-risks regression*; see stcrreg

compete required for finegray and specifies the events that are associated
with failure due to competing risks:

If compete(crvar) is specified, crvar is interpreted as an
indicator variable; any nonzero, nonmissing values are interpreted as
representing competing events.

If compete(crvar==numlist) is specified, records with crvar taking
on any of the values in numlist are assumed to be competing
events.

fixed(varlist) fixed variables

maxvar(integer) maximum number of variables included in the combinations; by default combinations are built with ALL independent variables

minvar(integer) minimum number of variables included in the combinations; by default 1

nohierarchical allow non hierarchical submodels; by default only hierarchical submodels are evaluated

using(filename) filename to store the results dataset; by default a dataset named
allsets_results is saved in the current (working) directory

noreplace if filename exists, do not replace; by default existing datasets are replaced

nst(string) name of the study (label)

*You must stset your data before using cox or finegray; see [ST] stset.

pweight is allowed for linear and logistic regression; see weight.

(weight on logistic regression will highly increase computation time)

You may use stset to weight your data before using cox or finegray; see [ST] stset.

Description

This command helps to find the best subset for Linear, Logistic, Cox and Competing-risks regression. All the
possible combinations of the independent variables are computed and evaluated to find a set
of parameters for each subset.

For Linear regression Mallow's Cp, Akaike Information Criteria (AIC), Schwarz Bayesian Criterion (BIC),
R-squared (R2) and adjusted R-squared (R2Adj) are computed for each subset.

For Logistic regression Akaike Information Criteria (AIC), Schwarz Bayesian Criterion (BIC), the Area Under the Curve (AUC),
Sensitivity (Se), Specificity (Sp), Hosmer-Lemeshow goodness-of-fit (pfitHL) and Pearson goodness-of-fit (pGof) are computed
for each subset. Hosmer-Lemeshow goodness-of-fit test is computed using 10 quantiles to group data: estat gof, group(10). Pearson
goodness-of-fit test is computed using: estat gof. To remove non fitting subsets from the results dataset, execute: drop if min(pfitHL, pGof)<0.10.

For Cox and Competing-risks regression Akaike Information Criteria (AIC), Schwarz Bayesian Criterion (BIC), Harrell's C (HarrellC) and
-2 logarithm of the likelihood (_2ll) are computed for each subset.

For Competing-Risk (Fine and Gray method) use stset, failure() to specify the failure
event of interest, that is, the failure event you wish to model using stcrreg. Use compete() to specify
the event or events that compete with the failure event of interest. Competing events, because they are not the failure
event of primary interest, must be stset as censored.

somersd user defined program is necessary to compute Harrell's C for Cox and Competing-risks regression. This module may be installed
from within Stata by typing ssc install somersd.

If maxvar or minvar option is used the significance of model test is computed for all types of regression and stored at
the pValue variable. If maxvar(1) the Coefficients of the linear regression (b variable), Odds Ratios of the logistic regression
(OR variable) or Hazard Ratios of the Cox and Competing-risks regression (HR variable) are stored on the results dataset.

The results are stored in a new dataset named by default allsets_results and stored in the current (working)
directory. Option using allows to use another path for results dataset. Existing datasets are replaced by default.

A maximum of 14 independent variables is recommended. For 14 variables 16383 submodels are estimated, and around 10
minutes of execution time is necessary. The number of estimated submodels and the execution time grows exponentially with each
added variable.

You can click here to pop up a dialog or type db allsets.

Execute net from http://metodo.uab.cat/stata for install.

It is important to keep the commands updated. Execute adoupdate allsets, update to update the allsets command.

Execute adoupdate, update to update all the user-written commands.

This command uses the regress, logit, logistic estat gof, lroc, rocreg, stcox, stcrreg,
estat concordance and _rmcoll Stata commands. It also uses the
somersd
user defined program.

If you find any bugs or want to suggest any improvements, please send an e-mail to: leam@uab.cat.

Examples

Linear regression

. use http://metodo.uab.cat/stata/allsets_linear.dta

. allsets Y X1 X2 B i.C, linear

. allsets Y X1 X2 B i.C, linear fixed(X1)

. allsets Y X1 X2 B i.C, linear maxvar(1)

. allsets Y X1 X2 B i.C c.X1#c.X2 c.X1#c.B, linear using(results_linear.dta)

Logistic regression

. use http://metodo.uab.cat/stata/allsets_logistic.dta

. allsets Y X1 X2 X3 i.C, logistic using(results_log.dta) noreplace

Cox regression

. use http://metodo.uab.cat/stata/allsets_cox.dta

. stset TR, failure(Estado==1)

. allsets X2 X3 i.C, cox using(results_cox.dta)

Time dependent covariates

. use http://metodo.uab.cat/stata/allsets_cox_vdt.dta

. stset Stop, id(Caso) failure(Estado==1) time0(Start)

. allsets X1 X2 X3 i.C c.X1#c.X2, cox

Competing-risk regression

. use http://metodo.uab.cat/stata/allsets_finegray.dta

. stset TSm, failure(Status==1)

. allsets X1 X2 i.C, finegray compete(Status==2)

Version

Version 1.3.6 -- 26 June 2025

Authors

JM.Doménech & JB.Navarro

Programmer: R.Sesma

Laboratori d'Estadística Aplicada

Universitat Autònoma de Barcelona

leam@uab.cat

Vancouver reference

Doménech JM, Navarro JB. Find the best subset for Linear, Logistic, Cox and Competing-risks Regression: User-written
command allsets for Stata [computer program].

V1.3.6. Bellaterra: Universitat Autònoma de Barcelona; 2022

Available executing from Stata: net from http://metodo.uab.cat/stata

References

Doménech JM, Navarro JB. Regresión múltiple con predictores categóricos y cuantitativos. 7ª ed. Barcelona: Signo; 2014.

Doménech JM, Navarro JB. Regresión logística binaria, multinomial, de Poisson y binomial negativa. 7ª ed. Barcelona: Signo; 2014.

Doménech JM, Navarro JB. Análisis de la supervivencia y modelo de riesgos proporcionales de Cox. 7ª ed. Barcelona: Signo; 2014.