# Transforming a matrix of explanatory variable in regression

Given the partitioned regression equation (into $$X_1$$ and $$X_2$$), I want to transform $$X_1$$, say $$X^*_1$$, such that $$X_2$$ and $$X^*_1$$ becomes orthogonal ie. $$X_2^T$$. $$X_1^*$$= 0. A matrix can be transformed as $$X_1^*$$ = $$X_1$$.p where P is transformation matrix.

If we premultiply $$X_1^*$$ = $$X_1$$.p with $$X_2^T$$ we will get $$X_2^T$$.$$X_1$$.p = $$X_2^T$$.$$X_1^*$$= 0. How can I find P?

Part (ii) is easy to solve. Parameters of $$X_2^T$$ and $$X_1^*$$ will depend on their separate regression with Y.

$$\boldsymbol X^*_1$$ is the residual of the projection of $$\boldsymbol X_1$$ on $$\boldsymbol X_2$$. The 'residual maker' matrix is $$\boldsymbol I - \boldsymbol X_2 \left(\boldsymbol X_2^T\boldsymbol X_2\right)^{-1}\boldsymbol X_2^T$$. Therefore, $$\boldsymbol X_1^* = \left(\boldsymbol I -\boldsymbol X_2 \left(\boldsymbol X_2^T\boldsymbol X_2\right)^{-1}\boldsymbol X_2^T\right)\boldsymbol X_1.$$