Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Panel data, statsby, dynamic forecasting


From   Christopher Baum <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Panel data, statsby, dynamic forecasting
Date   Sun, 15 Sep 2013 14:01:59 +0000

<>
On Sep 12, 2013, at 2:33 AM, Wesley wrote:

> I'm attempting to run a series of arima regressions within each region
> for a panel data set in long form. Following the arima regressions I'm
> attempting to do dynamic predictions so that I can iteratively
> forecast out of sample. Basically, the algorithm does a bunch of
> individual time series regressions and predictions. I have written a
> "foreach" loop with the "statsby" command to run the arima regressions
> across each region. The looping algorithm works; i.e., it runs the
> separate regressions and then performs the predictions, but the
> predictions are not calculated out of sample--it only performs the
> within sample predictions.
> 
> If I estimate the arima regression and prediction within a single
> region (i.e., omitting the rest of the panel) then the code works fine
> and the entire out-of-sample predictions are calculated. I think the
> problem may be related to how the time series command is automated in
> Stata. That is, if one uses a single region then the "tsset year"
> command is invoked, where year denotes my time observations which are
> annual. If one uses the "foreach" and "statsby" algorithm on a panel
> data set then the "tsset regions year" command must be invoked;
> otherwise, if you use the "tsset year" command on the panel then Stata
> provides the error code: "repeated time values in sample."
> 
> I would appreciate any feedback on how to fix this problem. The code
> is here, where the dynamic prediction is given a value of 2012 to tell
> Stata when to start the out-of-sample predictions. The term "lprod"
> designates a variable within my data set that is the log of production
> examined across time.

I had a similar issue with -fcast compute- after -var- or -vec-. When I raised the issue with Stata tech support this summer,
they suggested that -reshape wide- prior to -fcast- was the best way to proceed. I have a multi-country situation
where I want to run a separate VAR on each country, and produce forecasts. Converting the panel to wide (with
different countries' variables given different names) would solve the problem, if inelegantly. Presumably this could
be programmed as an ado so that you could readily estimate a multi-region VAR or VEC (or in your case an ARIMA) and have it
do the reshape wide, forecast, and then reshape everything back to long.

Kit

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                             An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
  An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html
                                                                                                      http://www.crup.com.cn/Item/111779.aspx     


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index