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
Fractional logit model for proportions over timeDear all, I have calculated a “Diversity Index” for a given population. Per the census website, the …
Multilevel model (binary outcome) with spatial weight matrix (not panel data)Hi Stata forum users, Does stata have any option to incorporate a spatial weight matrix with melogi…
Comparing age adjusted mortality ratesHello everyone. I am trying to compare age-adjusted mortality rate for two population. Rural age ad…
Fractional logit model for proportions over timeDear all, I have calculated a “Diversity Index” for a given population. Per the census website, the …
How to balance an unbalanced panel on the year variable?Hello everyone! I am fairly new to Stata and am unable to solve (perhaps) very basic problems. I am…
Subscribe to:
Post Comments (Atom)
0 Response to How to extract selected features from LASSO in stata
Post a Comment