Dear Statalist members,

I would like to plot a conditional (i.e. partial) relationship whose true functional form is quadratic. My general question is: does the logic of a linear added-variable (partial regression) plot carry over to the quadratic case?

Here's an example. Consider the following dataset and DGP.

Code:
set obs 1000
drawnorm x z e
gen z2 = z^2
gen y = 0.5*x - z + z2 + e
Here my main regression model:
Code:
reg y x z z2
If I want to plot the partial relationship between y and x, I could simply type
Code:
avplot x
, or:

Code:
qui reg y z z2
predict res_yz, res
qui reg x z z2
predict res_xz, res
twoway (scatter res_yz res_xz) (lfit res_yz res_xz)
reg res_yz res_xz
My first question is why in the last regression the standard error estimate is not identical to the corresponding estimate in the main regression and as reported by the avplot command.


Now, I would like to plot the partial relationship between y and z. If I residualise y and z and plot them, I obtain:

Code:
qui reg y x
predict res_yx, res
qui reg z x
predict res_zx, res
twoway (scatter res_yx res_zx) (qfit res_yx res_zx)
gen res_zx2 = res_zx^2
reg res_yx res_zx res_zx2

My second, and main, question: the partial relationship obtained here is not the same as in the main regression model (although it is similar). Why is this the case?


Many thanks for your help,

Luca J. Uberti
University of Luxembourg