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
Code:
reg y x z z2
Code:
avplot x
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
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
0 Response to Conditional scatterplot (partial regression plot) for a quadratic relationship
Post a Comment