Announcement

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

  • (Very Basic) Forecasting with Panel Data

    I'm trying to use Stata's forecasting interface (found under statistics > time series > forecasting) to develop VERY BASIC forecasts. My dataset includes 24 provinces across 30 years (1985 through 2014). I want to forecast the number of lawyers in each province to the year 2020. I will only use 2 variables to predict future lawyer counts: (1) year and (2) province.

    Here's my code:

    forecast create, replace
    xtset prov year
    xtreg lawyers yr, fe
    estimates store Forecast_Attempt1
    forecast estimates Forecast_Attempt1
    forecast solve, prefix(f_) begin(2014) end(2020)

    The 2014-2020 forecasts produced using this code are the same for all 24 provinces. This result tells me that Stata is not considering the province fixed effects in creating the forecasts. In an effort to get Stata to include these effects, I change the third line of the code from xtreg lawyers yr, fe to reg lawyers yr i.prov. These regressions are almost equivalent except that the latter one includes the province effects as dummy variables whereas the former subtracts out these effects prior to estimation. When I make this substitution and try to run the last line of the code, I receive the error message "command cannot be used with panel data."

    Can someone please help me? Please let me know if you need additional information.
    Last edited by Doug Bujakowski; 24 Mar 2017, 16:17.

  • #2
    Wecome to Statalist, Doug.

    If you replace your
    Code:
    xtset prov year
    with
    Code:
    xtset, clear
    Stata will no longer treat your data as panel data.

    Comment


    • #3
      Hi William,

      Thank you for the reply. To use Stata's forecasting interface, the data need to be set as either time series data or as panel data. As a result, xtset, clear won't work. Given that my data are panel data, I cannot set them as time series. Attempting to do so results in the error message "repeated time values in sample."

      To clarify my original question, I am wondering how to get Stata to include province fixed effects in the estimation of forecasts. So far, it seems that neither of the following two regression equations work: xtreg lawyers yr, fe and reg lawyers yr i.prov.

      If someone can point to a website or video which offers an example of someone using Stata's forecasting interface to forecast panel data, that would be extremely helpful. I've searched on my own for this, but cannot find such an example.

      Any and all advice is greatly appreciated. My dissertation depends on it. :-)

      Comment


      • #4
        Hello Doug,

        This video may interest you.
        Best regards,

        Marcos

        Comment


        • #5
          My apologies for oversimplifying my understanding of what you are attempting.

          It appears to me that you may have leapt ahead of yourself and need to spend some more time with the forecast documentation.

          The second example posed in help forecast includes the use of xtreg, fe. Or more thoroughly, see Example 3 in the forecast entry in the Stata Time-Series Reference Manual PDF included in the Stata installation (since version 11) and accessible from within Stata - for example, through Stata's Help menu.

          These suggest that following xtreg you need to use the predict command to predict the fixed or random error component, as described in help xtreg postestimation.

          Comment


          • #6
            I am also facing same issue on balanced panel data.

            Comment


            • #7
              Hello I have data of 50 countries from 1990 to 2018. We want to forecast analysis for three specific independent and one dependent variable till 2030. Data is balanced for all variables. Please guide me if its possible in Stata? How can we do this. I have tried lot of codes, but unable to generate graphs or estimates for 2030 or till 2025. The error messege is out of range..

              Comment

              Working...
              X