Hello everyone, I would like to predict the fitted values after a regression to explore the fitted line relationship with a given variable. Since I include more explanatory variables I want to explore the relationship at the mean of other variables. I was wondering if there's any way to do what I want with margins or predict. Here is an example of what I would like to do
I was hoping to use regress price c.mpg##c.mpg weight and then use margins or predict instead of having to calculate them the way I did.
Thanks for any pointers.
Code:
sysuse auto, clear generate mpgsq = mpg^2 regress price mpg mpgsq weight scalar b0 = _b[_cons] scalar b1 = _b[mpg] scalar b2 = _b[mpgsq] scalar b3 = _b[weight] summarize weight, meanonly scalar mwgt = r(mean) generate yhat = b0 + b1*mpg + b2*mpgsq + b3*mwgt twoway (line yhat mpg, sort)
Thanks for any pointers.
Comment