Hi,
I'am a bit puzzled as i got 2 different predictions from a simple quadratic regression (Y = aX +bX² + c), by 2 differents stata commands that i expected to be equivalent/exangeable.
Here is a reproductible example :
As you can see, there is a small difference between the 2 curves (i got another set of data were the difference is not neglectable)
I'am not sure were i'am wrong (Regress ≠ Twoway ?) or if i mess something ?
I'am a bit puzzled as i got 2 different predictions from a simple quadratic regression (Y = aX +bX² + c), by 2 differents stata commands that i expected to be equivalent/exangeable.
Here is a reproductible example :
Code:
sysuse auto, clear regress price mpg c.mpg#c.mpg /*** we fit a basic quadratic model with regress ****/ predict fitted /*** we get the predictions ****/ sort mpg /*** sort on mpg in order to use twoway line ***/ graph tw (scatter price mpg) /// /**** to get the scatter plot from crude values ****/ (line fitted mpg) /// /*** the fitted values from regress ***/ (qfit price mpg) /*** the quadratic fitted values from qfit ***/
I'am not sure were i'am wrong (Regress ≠ Twoway ?) or if i mess something ?
Comment