Announcement

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

  • Fitted regression line does not match ols output

    Hi,

    I estimated a simple linear regression model and got the following output:
    Click image for larger version

Name:	001.JPG
Views:	1
Size:	47.4 KB
ID:	1435914



    However, when i generated the fitted line on a graph, i got the following. The regression line seems to be too shallow as it looks as if the intercept is at a value of 4.4 instead of 6.14 as suggested by the ols output above. Note that 1985q1 is the first observation in the dataset.
    Click image for larger version

Name:	002.JPG
Views:	1
Size:	62.8 KB
ID:	1435915




    I hope i did not miss out anything. And thanks in advance for any help.




  • #2
    The intercept gives the value when time==0. Since you are using a SIF quarterly date, time==0 corresponds to 1960q1, not 1985q1.

    This was most likely an easy-to-make oversight on your part. But, if what I wrote is unclear, consider the following.

    Stata's "datetime" variables are complicated and there is a lot to learn. If you have not already read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF, do so now. If you have, it's time for a refresher. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

    All Stata manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

    Comment


    • #3
      time looks like a quarterly date. Therefore your predictions for 1985q1 and 2017q1 are (one line from Mata)

      Code:
      : 6.139225 :- 0.0176902 :* (yq(1985,1) \ yq(2017,1))
                     1
          +-------------+
        1 |   4.370205  |
        2 |  2.1058594  |
          +-------------+
      and all looks fine to me.

      The graph is easily explained by noting that the time origin would be plotted some distance to the left. yq(1960, 1) is 0.

      If this were my problem I'll reset to something like 2000q1 as origin -- so that the intercept is for then -- and perhaps use years as time units. It depends who is reading the report, but I doubt that any but experienced Stata users will immediately know both that the time origin is 1960q1 and that the time units are quarters, not years.

      More at

      SJ-15-2 st0394 . . . . . . . . . . . . . . Speaking Stata: Species of origin
      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
      Q2/15 SJ 15(2):574--587 (no commands)
      explores origins (some fixed and natural, others just
      conventional and sometimes not even convenient) and considers
      how best to model simple trends and seasonal periodicities as
      well as defining noncalendar years

      Naturally you should show the data too. The trend accounts for less than 8% of the variance, so the model is not very helpful on the face of it.

      Comment


      • #4
        Thanks William and Nick for your input.

        Yes, i just only realized that the origin starts from 1960q1.

        I have corrected for this by creating a new time variable assigning number 1 at 1985q1 (gen time2 = _n). and then regressed rpce on time2.



        The output now makes more sense. I note that the slope coefficient is similar although the intercept is now the correct one as i confirm by using the simple linear regression equations. This is a school assignment on fitting various time series models starting from the simple linear model to arima models. It is expected that this model wouldn't fit the data very well.

        I'm not sure how to reset the time origin away from 1960 so i won't have to go though the step of creating a new time variable like above, but i'll probably have to go through Nick's publication or stata's Help menu.

        Attached Files

        Comment

        Working...
        X