Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lasso postestimation OLS

    Hi! I am trying to run a Lasso regression for variable selection. Specifically I would like Stata to return the relevant coefficients from the Lasso approach and then run an OLS regression with those selected variables to get coefficients with standard errors. I am puzzled, however, which commands will get me there. I have been using "lasso linear" and then "lassocoef, display(coef, postselection)". I then read, however, to get standard errors I would need to run dsregress but this does not give me the coefficients for all my controls as I would like them to have. If you could explain that would be really helpful! Thank you!

  • #2
    The selected variables are stored in the macro -e(post_sel_vars)-. As your model is linear, you can use regress on the post-selection variables.

    Code:
    webuse cattaneo2
    lasso linear bweight c.mage##c.mage c.fage##c.fage ///
    c.mage#c.fage c.fedu##c.medu i.(mmarried mhisp ///
    fhisp foreign alcohol msmoke fbaby prenatal1)
    
    regress `e(post_sel_vars)'
    Res.:

    Code:
    . regress `e(post_sel_vars)'
    
          Source |       SS           df       MS      Number of obs   =     4,642
    -------------+----------------------------------   F(10, 4631)     =     29.44
           Model |    92938669        10   9293866.9   Prob > F        =    0.0000
        Residual |  1.4619e+09     4,631  315686.799   R-squared       =    0.0598
    -------------+----------------------------------   Adj R-squared   =    0.0577
           Total |  1.5549e+09     4,641  335032.156   Root MSE        =    561.86
    
    ------------------------------------------------------------------------------
         bweight |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            mage |   .4884131   1.840359     0.27   0.791    -3.119568    4.096394
            fedu |   2.238029   2.871845     0.78   0.436    -3.392155    7.868213
            medu |   4.848398   4.206963     1.15   0.249    -3.399253    13.09605
        mmarried |   150.5516    22.2432     6.77   0.000     106.9443    194.1588
           mhisp |   66.69611    49.8213     1.34   0.181    -30.97737    164.3696
         foreign |  -85.81082   39.73678    -2.16   0.031    -163.7138   -7.907803
         alcohol |  -57.24867   47.53726    -1.20   0.229    -150.4443      35.947
          msmoke |  -94.66951   9.680001    -9.78   0.000    -113.6469   -75.69209
           fbaby |  -58.15499    17.9433    -3.24   0.001     -93.3324   -22.97759
       prenatal1 |   48.49205   22.54524     2.15   0.032     4.292634    92.69146
           _cons |    3182.93   55.17699    57.69   0.000     3074.757    3291.104
    ------------------------------------------------------------------------------

    Comment

    Working...
    X