My read of "help cvlasso" is that e(varXmodel) should contain only variables chosen by cvlasso. However, it keep returning all of the variables, despite only a subset being chosen. Example of issue below (meaningly empirical example). Has anyone experienced this? Alternatively, does anyone have another way to get the selected variables (to be used elsewhere as variables in a regression)?
Thank you!
CODE:
local coeffs "total_duration max_duration tmmx tmmn vs sph pr mvs_10m snwd_s snow_s awnd_s wsf2_s wsf5_s"
local conditions "fe nf(5) lc(150) seed(1234)"
local sv "lse"
local estsample_dum "year>2015&year<2021&rand<=.8"
cvlasso cmi_dum `coeffs', `conditions' `sv', if `estsample_dum'&rand<.1
RESULTS:
K-fold cross-validation with 5 folds. Elastic net with alpha=1.
Fold 1 2 3 4 5
| Lambda MSPE st. dev.
----------+---------------------------------------------
1| 5380.1722 .06756452 .00049734
...cut...
14| 2408.8119 .06663226 .00047482 ^
...cut...
88| 24.84424 .06617284 .00047316 *
...cut...
* lopt = the lambda that minimizes MSPE.
Run model: cvlasso, lopt
^ lse = largest lambda for which MSPE is within one standard error of the minimal MSPE.
Run model: cvlasso, lse
Estimate lasso with lambda=2408.812 (lse).
---------------------------------------------------
Selected | Lasso Post-est OLS
------------------+--------------------------------
max_duration | 0.0437135 0.0838706
vs | 0.0008427 0.0071744
sph | 1.5681662 4.9519355
wsf5_s | 0.0003178 0.0003982
---------------------------------------------------
. dis e(varXmodel)
total_duration max_duration tmmx tmmn vs sph pr mvs_10m snwd_s snow_s awnd_s wsf2_s wsf5_s
. dis e(varX)
total_duration max_duration tmmx tmmn vs sph pr mvs_10m snwd_s snow_s awnd_s wsf2_s wsf5_s
. dis e(partial)
.
Related Posts with Getting selected variables from cvlasso
Non-linear regression with industry and year FEDear colleagues, Greetings! I have been searching different forums for the past weeks, but the mor…
Coding_column_rowDear statalist community, I am in need to do the following exercise for my research, can anyone plea…
the `tebounds’ command - bound the average treatment effectHi Statalists, I am reaching out with some questions regarding the `tebounds’ command. I am wonderi…
Poisson regression without specifying exit variableI am conducting an analysis using a longitudinal dataset from an ongoing cohort that spans over 5.5 …
Issues running ranksum - says "no observations found"I'm relatively new to Stata so I am hoping that this error is a quick fix. I've been trying to run …
Subscribe to:
Post Comments (Atom)
0 Response to Getting selected variables from cvlasso
Post a Comment