Announcement

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

  • Selected variable list using lasso

    Hi All,

    I have data which resembles the following:



    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(y x1 x2 year)
    2 2 2 1991
    3 3 3 1990
    1 4 4 1990
    4 1 1 1991
    1 2 2 1990
    4 3 3 1990
    end
    [/CODE]

    Here, I wish to run a lasso regression of y on x1, x2 and year dummies, in order to select relevant regressors (between x1 and x2 in this example). In order to do this, I run:

    Code:
    lasso2 y x1 x2  (year) , lic(aicc)  long
    Here, I choose the model using AICC, and I insert parentheses in order to specify that year dummies should be included, regardless of whether or not they are assigned a 0 coefficient using lasso. In doing so, however, the year dummies which are not significant, have still be dropped. I have two questions.

    1. How can I force the model to include all year dummies in this case, and only select between x1 and x2?
    2. How can I store the variable list which is selected in a local macro for use at a later point?

    Many thanks for your consideration.

    CS



  • #2
    You can't. And I don't think it's possible aside from modifying the command

    Comment


    • #3
      Originally posted by Jared Greathouse View Post
      You can't. And I don't think it's possible aside from modifying the command

      Thank you. Although I understand I cannot force some variables to be included no matter what, I must be able to retrieve the selected variable list, no?


      Comment


      • #4
        The way you CAN do it is either by using the predict postestimation command (which will show you, but can't save it), or.......... you can do what Fernando says here

        Comment


        • #5
          Thank you so much!! Very helpful.

          Comment

          Working...
          X