Announcement

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

  • Question re Margins following LASSO

    Hi everyone,

    So, in short, I am running a linear LASSO, and following that, when I'm trying to estimate the Average Marginal Effect--i.e. to use the 'margins' command--I get an error message, telling me that I can use the margins command following LASSO. Any idea why, and what could be done about it if what I'm eventually looking for is estimating the Average Marginal Effect?

    Thank you in advance!
    Erez

  • #2
    Are you using the official lasso? If so, what you get are selected variables, but no regression is run. You have to do this yourself. With no interactions or higher order terms, the coefficients are themselves marginal effects in linear regression.

    Comment


    • #3
      Thanks for your response, Andrew.
      I am indeed using the official lasso. So what I don't understand then is what the "prediction" command tells me, when I run it after running the LASSO.
      Thanks again!

      Comment


      • #4
        See https://www.stata.com/manuals/lassolasso.pdf. You have 2 choices; penalized coefficients after lasso (the default) or post-selection or unpenalized coefficients. You can replicate the post selection coefficients' regression using the saved variable list.

        Code:
        webuse cattaneo2, clear
        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)
        predict bweighthat1, postselection
        
        *RUN REGRESSION
        regress `e(depvar)' `e(othervars_sel)'
        *PREDICT
        predict bweighthat2,xb
        Res.:

        Code:
        . l b*hat* in 1/20, sep(0)
        
             +---------------------+
             | bweigh~1   bweigh~2 |
             |---------------------|
          1. | 3506.369   3506.369 |
          2. | 3196.155   3196.155 |
          3. | 3367.939   3367.939 |
          4. | 3478.909   3478.909 |
          5. | 3428.582   3428.582 |
          6. | 3276.363   3276.363 |
          7. | 3487.147   3487.147 |
          8. | 3420.344   3420.344 |
          9. | 3407.987   3407.987 |
         10. | 3506.712   3506.712 |
         11. | 3171.036   3171.036 |
         12. | 3276.363   3276.363 |
         13. | 3496.758   3496.758 |
         14. | 3392.883   3392.883 |
         15. | 3228.592   3228.592 |
         16. |  3474.79    3474.79 |
         17. | 3483.028   3483.028 |
         18. | 3517.353   3517.353 |
         19. | 3478.909   3478.909 |
         20. | 3071.944   3071.944 |
             +---------------------+

        Comment


        • #5
          Thank you! Much appreciated

          Comment


          • #6
            Hello again,
            Quick question regarding the example above: it seems as it while the predicted values for each of these two options are similar, the coefficients are not.
            Is that indeed the case or am I imagining things?
            Thank you for your time!
            Erez

            Comment


            • #7
              Not sure what you mean by #6. In #4, I differentiated between the penalized coefficients and the post-selection coefficients. So look at the latter, not the former.

              Comment

              Working...
              X