Hi
I have several variables at each week of the quarter (12 weeks per quarter in a stylized calendar).
I want to run a lasso or ridge regression (elasticnet) to produce forecasts of quarterly GDP at each given week (WK) using ALL past information for a particular week.
I have done the following to do this:
Code:
gen forecast=.
levelsof WK, local(levels)
foreach x of local levels {
forvalues j=170(1)241 {
quietly lasso linear GDP var1-var500 if inrange(quarter_date,85,`j') & WK==`x'
estimates store lasso
predict tem_`j', postselection
replace forecast=tem_`j' if WK==`x'
drop tem_`j'
}
}
The problem is that in practice the dependent variable GDP is not available during the quarter while all other independent variables are available. Therefore, ideally, the regression should be estimated using all lagged variables (something like: quietly lasso linear lag_rgdp_first lag_var1-lag_var500 if inrange(quarter_date, 85, `j') ) and then the coefficients should be estimated. Once the coefficients are estimated, I can then produce more realistic forecasts that are sort of out-of-sample as follows:
Code:
gen forecast = b_cons + b_lagvar1 * var1 + b_lagvar2 * var2 + b_lagvar3 * var3 + ...... if WK==`x'
In particular, I am not interested in the coefficients as the number of variables is very large anyways but I want to estimate realistic forecasts for the current quarter GDP without using the current quarter GDP variable in the regression. My aim of showing the forecast in the previous code is for you to see how they should be estimated in line with my objective.
Can anyone help with coding this?
I look forward to hearing from you
0 Response to Generating current quarter forecasts using only past data when the number of variables is very large
Post a Comment