Hi all,
I came across a problem when implementing the Stata lasso predict command. What I was running is:
(in a loop)
...
predict `var'_p, xb postselection
....
I checked the predicted outcomes and found some of them are missing. For all the missing predictions, I notice that the variables selected by Lasso include a weird " __000001". I suspect this is a misgenerated global macro by Stata lasso command, which causes the failure of prediction. Here is an example of a model selected by Lasso which fails to predict:
------------------------------------------
| CV_min_genhealthFpr_1
-------------------+----------------------
_CLDlngtmhthyn_b | x
_dntenryn3_b | x
_dntenryn5_b | x
_CLDalonedaysb | x
_nooxcurrsb | x
_PRGpntlenc_bi3 | x
_CLDhealthrel_bi4 | x
_CLDfreqmilk_bi1 | x
_vigphysfreqF_bi3 | x
_genhealthF_bi2 | x
_genhealthF_bi4 | x
_COGdprssdchrF_bi2 | x
_COGbumpF_bi2 | x
_edu2_bi4 | x
_inschrsn11_bi14 | x
_inschrsn12_bi5 | x
_inschrsn14_bi13 | x
_prijobind4_bi18 | x
_prijobind4_bi23 | x
_prijobind4_bi26 | x
_prijobind5_bi17 | x
_wtrsrcfar_bi1 | x
_latrinetype_bi2 | x
_genhealthM_bi3 | x
_upchestpainM_bi1 | x
_COGtiredrsnM_bi5 | x
_notawasb_sq | x
_nojwlsvsb_sq | x
_soldlandrssb_sq | x
_hhmineassc_b_mi | x
_othhhsamelat_b_mi | x
__000001 | x
_cons | x
------------------------------------------
My question is, is there any way to get rid of this "__000001"? If not, can I do the post selection prediction manually, by which I would like to use all the post selection variables except "
. local var e(allvars_sel)
. display `var'
_CLDlngtmhthyn_b _dntenryn3_b _dntenryn5_b _CLDalonedaysb _nooxcurrsb _PRGpntlenc_bi3 _CLDhealthrel_bi4 _CLDfreqmilk_bi1 _vigphysfreqF_bi3 _genhealthF_b
> i2 _genhealthF_bi4 _COGdprssdchrF_bi2 _COGbumpF_bi2 _edu2_bi4 _inschrsn11_bi14 _inschrsn12_bi5 _inschrsn14_bi13 _prijobind4_bi18 _prijobind4_bi23 _pri
> jobind4_bi26 _prijobind5_bi17 _wtrsrcfar_bi1 _latrinetype_bi2 _genhealthM_bi3 _upchestpainM_bi1 _COGtiredrsnM_bi5 _notawasb_sq _nojwlsvsb_sq _soldland
> rssb_sq _hhmineassc_b_mi _othhhsamelat_b_mi __000001
. local exclude __000001
.
. local post_sel_vars: list vars - exclude
.
. display `post_sel_vars'
Any help/insight is very much appreciated!
I came across a problem when implementing the Stata lasso predict command. What I was running is:
(in a loop)
...
predict `var'_p, xb postselection
....
I checked the predicted outcomes and found some of them are missing. For all the missing predictions, I notice that the variables selected by Lasso include a weird " __000001". I suspect this is a misgenerated global macro by Stata lasso command, which causes the failure of prediction. Here is an example of a model selected by Lasso which fails to predict:
------------------------------------------
| CV_min_genhealthFpr_1
-------------------+----------------------
_CLDlngtmhthyn_b | x
_dntenryn3_b | x
_dntenryn5_b | x
_CLDalonedaysb | x
_nooxcurrsb | x
_PRGpntlenc_bi3 | x
_CLDhealthrel_bi4 | x
_CLDfreqmilk_bi1 | x
_vigphysfreqF_bi3 | x
_genhealthF_bi2 | x
_genhealthF_bi4 | x
_COGdprssdchrF_bi2 | x
_COGbumpF_bi2 | x
_edu2_bi4 | x
_inschrsn11_bi14 | x
_inschrsn12_bi5 | x
_inschrsn14_bi13 | x
_prijobind4_bi18 | x
_prijobind4_bi23 | x
_prijobind4_bi26 | x
_prijobind5_bi17 | x
_wtrsrcfar_bi1 | x
_latrinetype_bi2 | x
_genhealthM_bi3 | x
_upchestpainM_bi1 | x
_COGtiredrsnM_bi5 | x
_notawasb_sq | x
_nojwlsvsb_sq | x
_soldlandrssb_sq | x
_hhmineassc_b_mi | x
_othhhsamelat_b_mi | x
__000001 | x
_cons | x
------------------------------------------
My question is, is there any way to get rid of this "__000001"? If not, can I do the post selection prediction manually, by which I would like to use all the post selection variables except "
__000001"? I am trying to extract the list of selected variables from
e(allvars_sel), but it seems doesn't work:. local var e(allvars_sel)
. display `var'
_CLDlngtmhthyn_b _dntenryn3_b _dntenryn5_b _CLDalonedaysb _nooxcurrsb _PRGpntlenc_bi3 _CLDhealthrel_bi4 _CLDfreqmilk_bi1 _vigphysfreqF_bi3 _genhealthF_b
> i2 _genhealthF_bi4 _COGdprssdchrF_bi2 _COGbumpF_bi2 _edu2_bi4 _inschrsn11_bi14 _inschrsn12_bi5 _inschrsn14_bi13 _prijobind4_bi18 _prijobind4_bi23 _pri
> jobind4_bi26 _prijobind5_bi17 _wtrsrcfar_bi1 _latrinetype_bi2 _genhealthM_bi3 _upchestpainM_bi1 _COGtiredrsnM_bi5 _notawasb_sq _nojwlsvsb_sq _soldland
> rssb_sq _hhmineassc_b_mi _othhhsamelat_b_mi __000001
. local exclude __000001
.
. local post_sel_vars: list vars - exclude
.
. display `post_sel_vars'
Any help/insight is very much appreciated!
Comment