I want to remove impact of an independent variable (x1) in a multi variable liner regression model that has two independent variables x1 and x2. Would the following approach be correct to do that?
- Do regression between dependent variable y and independent variable x2
- Get residuals from model in step 1
- Do regression between residual as dependent variable and x1 as independent variable
- Run predict on model in step 3
- Subtract predictions in step 3 from y to get adjusted_y
I am doing this in R
------------------------------
Parag Kulkarni
------------------------------