Good afternoon,
I encountered the following mysterious behaviour of -predict- , which I cannot rationalise by anything that I know regarding how Stata works.
1. I run a regression of price on mpg, and I predict the residual. (Standard scenario, the benchmark. )
2. I drop the regressor mpg, and try again to predict.
a) When I call the predicted value an arbitrary name, Stata behaves as expected and tells me that it cannot find the regressor mpg, and hence is unable to calculate the predictions.
b) The mystery occurs when I call the predicted values by the name of the missing regressor mpg. Stata does not report any problem, and calculates something, I am not sure what...
Does anyone have any guess what just happened here?
I encountered the following mysterious behaviour of -predict- , which I cannot rationalise by anything that I know regarding how Stata works.
1. I run a regression of price on mpg, and I predict the residual. (Standard scenario, the benchmark. )
2. I drop the regressor mpg, and try again to predict.
a) When I call the predicted value an arbitrary name, Stata behaves as expected and tells me that it cannot find the regressor mpg, and hence is unable to calculate the predictions.
b) The mystery occurs when I call the predicted values by the name of the missing regressor mpg. Stata does not report any problem, and calculates something, I am not sure what...
Code:
. sysuse auto, clear (1978 Automobile Data) . keep price mpg . keep in 1/5 (69 observations deleted) . qui reg price mpg . predict correctresidual, resid . list correctresidual +-----------+ | correct~l | |-----------| 1. | 293.3505 | 2. | -1292.99 | 3. | -6.649485 | 4. | 115.8144 | 5. | 890.4742 | +-----------+ . drop mpg . predict wrongresidual, resid variable mpg not found r(111); . predict mpg, resid . list mpg +-----------+ | mpg | |-----------| 1. | 8.00e+24 | 2. | 4.25e+24 | 3. | -9846.547 | 4. | 1.38e+35 | 5. | 3.22e+34 | +-----------+ .
Comment