Announcement

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

  • Forecast Panel Data (''repeated time values'')

    Hi everyone, I am Martin. I posted a few days ago a post about a model I was trying to forecast, however, I did not get any help.
    I will try to be more specific now in terms of data details, so I can hopefully get an answer.

    What I am trying to do is to forecast the 'happiness' based on weather variables, basically, how weather affects the happiness of the people in different countries. My data looks like:

    YEAR / COUNTRY / HAPINESS / PRECIPITATION / AVG TEMP / ... / etc
    2000 US 1 23
    2001 US 1 34
    2002 US 1 63
    ....
    2021 US 1 55
    2000 NORWAY 2 64
    2001 NORWAY 2 89
    2002 NORWAY 2 89
    ....
    2021 NORWAY 2 100

    I am trying to do 2 things:
    1. Forecast what the Hapiness variable (dependent variable) will be in 2022. Result and graph.
    2. See how my model did compared to the real results (I do have the happiness values for the countries I have, and I coded them according to a ranking). Therefore, would like to graphically see how was the standard error of the model results and the real results.

    Many thanks in advance.

    Martin

  • #2
    In order to add more information, as I see I did not include everything, the code I was running was:

    CODE:
    tsset Hapiness Year
    the error I encounter is: ''repeated time values within panel''.

    Therefore, when forecasting, and due to I have to use either time settings or panel settings, I cannot create the forecast model.

    Hope it is clear and thank you very much for the help.

    Comment


    • #3
      I suspect you should instead do

      Code:
      tsset COUNTRY YEAR
      With -tsset- you specify your panel variable and your time variable. What variable you wish to model or forecast is irrelevant as far as -tsset- is concerned.

      Comment


      • #4
        Hi Brian. Thank you so much for your response.
        The issue when running the code you mentioned is that the 'Country_Codes' (how i called it), have as well repeated values.

        Therefore, I get:
        tsset Country_Code Year
        repreated time values within panel

        Comment


        • #5
          Can you explain how your data could have more than one observation for a given combination of country and year?

          If not, then your data is not as you understand it to be, because Stata is telling you that in at least one case the same country has more than one observation in a given year, and you will need to deal with this before you can proceed.

          See the output of
          Code:
          help duplicates
          for documentation of commands that will help you find the duplicated observations that are causing the problem. I suggest:
          Code:
          duplicates tag Country_Code Year, gen(flag)
          browse if flag
          That will show you the offending observations and then you can figure out how to fix this.

          Comment


          • #6
            Thank you so much both. It was indeed the issue William was mentioning...dummy me! Thanks a lot.

            Comment

            Working...
            X