Announcement

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

  • Predict a specific out-of-sample value in stata

    Hi all,

    Firstly, sorry if this has been asked before. But i couldn't find answers in the manual or in the forum on this.

    I want to make a specific out-of-sample point forecast, but using the predict command does not seem to work. For example, I have a data set with 50 observations of GDP data over a period 1961 - 2010. I created a dummy time variable gen time = _n, and want to do a simple linear model and generate a one-period-ahead forecast at period t=51. These are my steps:

    1) reg GDP time
    2) set obs 60
    3) predict gdphat1 if time>(50)
    (option xb assumed; fitted values)
    (60 missing values generated)

    Example of my dataset:

    Year GDP time
    ....
    2008 166792.3 48
    2009 175934.9 49
    2010 213154.5 50
    ...

    Doing the 3rd step returned all missing values. How do we specifically generate the 51st value? (of course i know how to do this manually, but i was wondering if stata can do this)


    Thanks in advance.





    Last edited by Benson Tay; 17 Mar 2018, 03:13.

  • #2
    Benson:
    welcome to the list.
    I'm under the impression that Stata needs new observations with the same variables to calculate automatically what you're after.
    For further details, please see Examples 1-2 , -regress postestimation- entry, Stata .pdf manual.
    As an aside, please use CODE delimiters (see the FAQ on this and other posting-related topics) to share what you typed and what Stata gave you back. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      An alternative might be to use the margins command with the values of the x's you want.

      Comment


      • #4
        Thank you. I've found out how to do it.

        Comment


        • #5
          Hello Benson,

          Would you care to share how you did it?

          Br,
          Martin

          Comment

          Working...
          X