Announcement

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

  • cvlasso - negative numbers for observation index

    Achim Ahrens
    ​​​​​Dear Stata Experts,

    I have installed the Stata Lasso Pack on my version of Stata (Stata 16.1 on Mac OS).

    I have a dataset with several time series with 268 observations. I want to see whether lags of variable X are able to predict variable Y. I want to use a fixed length rolling window and starting my validation from observation 201.
    Therefore, I am using the following command from the Stata Lasso Pack.

    Code:
    cvlasso Y L(1/8).X, rolling origin(200) fixedwindow lopt
    The code works, however, I was expecting my rolling window to be something like 8-220 (221) , 9-221 (222) .... and so on and so forth. However, the code uses negative indexation to denote my observations and spits out something like:
    Code:
    Training from-to (validation point): -36-200 (201), -35-201 (202),
    basically it starts counting observations with negative numbers. This is very confusing and I don't know what is going on.
    Any suggestion?

    Best,
    Edoardo

  • #2
    Hi Edoardo, thanks for your question. I cannot reproduce this on my end, see example below. Before I dig deeper, can you let me know which lassopack version you are using? Latest version can be installed from github.

    Code:
    clear
    set seed 42
    set obs 268
    gen t = _n
    tsset t
    gen e = rnormal()
    gen x = rnormal()
    gen y = 0.1*L.x + e
    Code:
    . which cvlasso
    /Users/kahrens/Library/Application Support/Stata/ado/plus/c/cvlasso.ado
    *! cvlasso 1.0.11 27sept2020
    *! lassopack package 1.4.2
    *! authors aa/ms
    
    .
    . cvlasso y L(1/8).x, rolling origin(200) fixedwindow lopt
    Rolling forecasting cross-validation with 1-step ahead forecasts. Elastic net with alpha=1.
    Training from-to (validation point): 9-200 (201), 10-201 (202), 11-202 (203), 12-203 (204), 13-204 (205), 14-205 (206)
    > , 15-206 (207), 16-207 (208), 17-208 (209), 18-209 (210), 19-210 (211), 20-211 (212), 21-212 (213), 22-213 (214), 23
    > -214 (215), 24-215 (216), 25-216 (217), 26-217 (218), 27-218 (219), 28-219 (220), 29-220 (221), 30-221 (222), 31-222
    >  (223), 32-223 (224), 33-224 (225), 34-225 (226), 35-226 (227), 36-227 (228), 37-228 (229), 38-229 (230), 39-230 (23
    > 1), 40-231 (232), 41-232 (233), 42-233 (234), 43-234 (235), 44-235 (236), 45-236 (237), 46-237 (238), 47-238 (239),
    > 48-239 (240), 49-240 (241), 50-241 (242), 51-242 (243), 52-243 (244), 53-244 (245), 54-245 (246), 55-246 (247), 56-2
    > 47 (248), 57-248 (249), 58-249 (250), 59-250 (251), 60-251 (252), 61-252 (253), 62-253 (254), 63-254 (255), 64-255 (
    > 256), 65-256 (257), 66-257 (258), 67-258 (259), 68-259 (260), 69-260 (261), 70-261 (262), 71-262 (263), 72-263 (264)
    > , 73-264 (265), 74-265 (266), 75-266 (267), 76-267 (268).
    --
    Tag me or email me for ddml/pdslasso/lassopack/pystacked related questions. I don't check Statalist.

    Comment

    Working...
    X