Announcement

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

  • lfit intercept

    Using auto.dta, a regression of price against miles per gallon yields an intercept of 11,253.06.

    The command twoway (scatter price mpg) (lfit price mpg) produces the following graph...
    Click image for larger version

Name:	figure1.png
Views:	1
Size:	41.0 KB
ID:	1400048



    ...where the fit line is clearly going to intercept the y axis below 10,000, contradicting the regression output.

    However, we can tell Stata to draw the fit line only over a certain range of the regressor by typing, for example, twoway (scatter price mpg) (lfit price mpg, range(0 20))
    Click image for larger version

Name:	figure2.png
Views:	1
Size:	18.3 KB
ID:	1400049



    The fit line now seems to be (correctly) headed towards the intercept of the regression output.

    What is going on?

    P.S. I would imagine someone already noticed this, but I couldn't find anything through the search. Also, the link to the pre-April 2014 archives is not working anymore. What's up with that?

  • #2
    1. The default fit shown is correct. It just doesn't make explicit the axis line x = 0 so that you can see the intercept as such. Sometimes for pedagogical purposes you may want to make that explicit, and you can do that by extending the range. I don't accept that it would be a good default always to show x = 0 here. (I find that my aaplot (SSC) behaves similarly in this example.)

    2. I find the archives https://www.stata.com/statalist/archive/ to be working fine. Some one in Portugal did long ago have an archive of all the posts from the beginning, as I recall, but that disappeared years ago. I don't know whether Alvaro was looking for some other version. It may be that the Harvard version has disappeared.

    Comment


    • #3
      Oh, I see. The x axis is just chopped at 10 in the default graph. Thanks!

      Regarding the archive, I meant the link that appears on this header when we are writing a post:

      Click image for larger version

Name:	archive.png
Views:	1
Size:	16.0 KB
ID:	1400059



      The page https://www.stata.com/statalist/archives/ apparently doesn't exist anymore or is undergoing maintenance.

      Comment


      • #4
        The regression output for the intercept 11,253.06 is the intercept when mpg=0 (∂y/∂x). Problem is 'mpg' does not have a 'zero' in its range as it ranges from 12 to 41. While 'twoway scatter' correctly finds the intercepts in relation to when 'mpg' = 0, the regression output does not represent the right intercept. If you rescale 'mpg' and allow a 'zero' in its range, the output will match:

        Code:
        gen mpgsc = mpg-12 //Rescale mpg from its minimum value; you can also rescale by centering the mean
        
        reg price mpgsc //regression with mpg-rescaled
        
        
              Source |       SS           df       MS      Number of obs   =        74
        -------------+----------------------------------   F(1, 72)        =     20.26
               Model |   139449474         1   139449474   Prob > F        =    0.0000
            Residual |   495615923        72  6883554.48   R-squared       =    0.2196
        -------------+----------------------------------   Adj R-squared   =    0.2087
               Total |   635065396        73  8699525.97   Root MSE        =    2623.7
        
        ------------------------------------------------------------------------------
               price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
               mpgsc |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
               _cons |   8386.329    580.115    14.46   0.000      7229.89    9542.767
        ------------------------------------------------------------------------------
        
        //Two-way scatter with mpg-rescaled
        
        twoway (scatter price mpgsc) || (lfit price mpgsc), yline(8386.329)
        Click image for larger version

Name:	mpg.png
Views:	1
Size:	180.4 KB
ID:	1400065
        Roman

        Comment


        • #5
          To resolve the archives question:

          As said in #2 the archives are at https://www.stata.com/statalist/archives/

          If you click on the link copied in #3 the forum software attempts a link to http://www.stata.com/statalist/archives/

          Note the difference. https is the protocol now used.

          Thanks to Alvaro for pointing towards this. I've alerted StataCorp so the link can be fixed.

          Comment

          Working...
          X