Announcement

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

  • #16
    Originally posted by Jared Greathouse View Post
    Try
    Code:
    tsset panelvar year, y

    That one worked!
    Yet, I am still getting on the display


    Code:
    Rolling forecasting cross-validation with 1-step ahead forecasts. Elastic net with alpha=1. Training from-to (validation point):
    Code:
    1980-2003
    (2004), 1980-2004 (2005), 1980-2005 (2006), 1980-2006 (2007), 1980-2007 (2008), 1980-2008 (2009), 1980-2009 (2010), 1980-2010 (2011), 1980-2011 ( 2012), 1980-2012 (2013), 1980-2013 (2014).
    [ Again, predicted cf is produced after 1980
    .

    The full code I run is


    tsset panelvar year, y

    cvlasso growthgdp l.gdp cpi u

    Output dummy1 dummy2 c.indicator1##c.indicator1, h(1) roll postres plotcv

    cvlasso, lopt postres mat l e(beta) predict cf, xb residuals lopt noisily
    I did not do any order or other sort by in the dataset nor
    greshape long or `int_time',1,0) as you have in #10 and #11
    Data are already ordered by panel year,\\`
    Any ideas please?

    Comment


    • #17
      Since I think I created a mess with my previous reply and was not able to edit the post, I post again my reply and codes.
      tsset panelvar year, y
      Worked.

      So here is the full code I run






      tsset panelvar year, y

      cvlasso growthgdp l.gdp cpi u Output dummy1 dummy2 c.indicator1##c.indicator1, h(1) roll postres plotcv

      cvlasso, lopt postres

      mat l e(beta)

      predict cf, xb residuals lopt noisily
      .

      On display, I get
      [QUOTE]
      Rolling forecasting cross-validation with 1-step ahead forecasts. Elastic net with alpha=1. Training from-to (validation point): 1980-2003 (2004), 1980-2004 (2005), 1980-2005 (2006), 1980-2006 (2007), 1980-2007 (2008), 1980-2008 (2009), 1980-2009 (2010), 1980-2010 (2011), 1980-2011 (2012), 1980-2012 (2013), 1980-2013 (2014) [/QUOTE ]

      Predicted values are still generated from 1980, ignoring the first 35 or so years. Data contain gaps. Any idea why is this happening?

      Comment


      • #18
        I suspect it's the gaps that are the problem.

        Comment


        • #19
          Originally posted by Jared Greathouse View Post
          I suspect it's the gaps that are the problem.
          Could I reduce the Training from-to (validation point) length, or I should leave with that? I read about k-folder in the help file, but did not get how it is done. Anyway, thank you so much for the code and everything!

          Comment


          • #20
            Here's my question... what exactly do you wanna use the LASSO for?

            Comment


            • #21
              Originally posted by Jared Greathouse View Post
              Here's my question... what exactly do you wanna use the LASSO for?
              I have a large database with macroeconomics variables, some kind of quality indicators, which their interactions are seen from the quadratic relation above in #17, a bunch of categorical and dummies. I need to shrink the variables selected for the estimation to a more parsimonious model . Mostly the issue is caused by the dummies, categorical variables and the quadratic relation. Even now, after LASSO, I am ending with more 70 covariates at the RHS. Not the best way to run a dynamic panel
              Last edited by Giorgio Di Stefano; 21 Jun 2022, 20:23.

              Comment


              • #22
                Jared Greathouse I though should share this just as an update for people in the future looking for it. I 've run a cvlasso with both lopt and lse option, on lamba. For lopt, predictions start from 1980, while for lse from 1970. Gained a decated of new predictions with the lse option. I think you are right. Gaps do matter in the data and higher the lampa larger the predictions generated in time . I 've tested it by imposing arbitrary values of lampa. At least in my case that was showed. May be that will not stand for others or that is even completely wrong.
                My understanding is that predictions generated are on the dependent variable Y values, not coefficients. Am I right on that?

                Comment


                • #23
                  You don't wanna choose values of lambda, the CV procedure should do that.

                  But the more pertinent thing for you i think is to rid yourself of the gaps. In my command for example, I demand that the users have a balanced panel dataset before use, or they can't run it. but yeah, the coefficients are about the outcome. In my case, prediction is natural because it's explicitly a causal inference design in a panel data setting

                  Comment


                  • #24
                    Originally posted by Jared Greathouse View Post
                    You don't wanna choose values of lambda, the CV procedure should do that.

                    But the more pertinent thing for you i think is to rid yourself of the gaps. In my command for example, I demand that the users have a balanced panel dataset before use, or they can't run it. but yeah, the coefficients are about the outcome. In my case, prediction is natural because it's explicitly a causal inference design in a panel data setting

                    Thank you so much once again for your help , Jared !. I appreciate that!
                    I let cvlasso to choose lambda. I just wanted to understand a bit how it works, so I played around a bit

                    I tried to fill the gaps using the tsfill, full command
                    tsfill, full

                    . tsset id year, y
                    panel variable: id (strongly balanced)
                    time variable: year, 1945 to 2020
                    delta: 1 year
                    Still, I got the same results for prediction. One thought I made was to fill the gaps with the first available observation back to the origin of the time series, but that would result to unrealistic assumption. Some countries of my sample did not even exist at that time! Frankly, I do not know or think of anything else !


                    Thanks for everything!








                    .




                    Last edited by Giorgio Di Stefano; 23 Jun 2022, 19:08.

                    Comment

                    Working...
                    X