Hi,
I have somewhat of a basic question. I am running the lasso linear command and wanted to use that to extract the selected variables and then use them for another estimation.
From what I can tell, I am interested in extracting e(post_sel_vars). However, since I am an R user, I don't know how to extract the vector of variables selected (please note that I am not interested in the coefficients but rather the variable names).
This is what I have right now (the parts highlighted in bold are wrong):
foreach var in $outcome_vars {
lasso linear `var' (i.report_month i.report_year i.tehsil_level i.ao) $ability_vars $network_vars $agsmart_indicators $interactions , selection(adaptive) cluster(end_tehsil) noconstant
//ereturn list
local selected_vars = e(post_sel_vars)
//lassocoef lassoadaptive, display(coef, standardized)
xtreg `var' subplus `selected_vars', i(ao) nonest fe
}
Any help would be greatly appreciated!
Thanks,
Bhavya
Related Posts with How to extract selected features from LASSO in stata
Multiple !inlist functions do not catch an errorHi All, I am trying to capture an error when a user does not correctly specify an option requiring …
Creating Lagged Variables for Last Month of Financial YearHi there, I need to create lagged variables to run as part of a Fama-MacBeth regression, and asreg …
Calculate the change in panel data.Hi Statalists, I have a panel data of 3200 firms for time span from 2004 to 2018 which contains the …
Power calculation- cross-over designHello, Does anyone have experience with power calculations in STATA for a crossover design? Trying …
Correct use of year-dummy in margins commandI am using a Panel Data with two waves and I have a year dummy indicator for the second year: y.2017…
Subscribe to:
Post Comments (Atom)
0 Response to How to extract selected features from LASSO in stata
Post a Comment