# Least Squares Matrix Notation Correlation

Consider the model $Y = b_0 + b_1 x_1 + b_2 x_2 + \epsilon$, where the columns $x_1$ and $x_2$ of the design matrix have mean 0 and length 1. That is $x_i' x_i = 1$, and $x_i' J = 0$, for $i = 1, 2$, where $J$ is a vector consisting entirely of ones. Let $p$ be the correlation between $x_1$ and $x_2$.

Show that, \begin{align}X'X & = \begin{pmatrix} n & 0 & 0 \\ 0 & 1 & p \\ 0 & p & 1 \end{pmatrix} \end{align} .

**I can easily show that numerically with a $3 \times 3$ matrix of: \begin{align}X & = \begin{pmatrix} 1 & -\sqrt{.5} & -\sqrt{.5} \\ 1 & 0 & 0 \\ 1 & \sqrt{.5} & \sqrt{.5} \end{pmatrix} \end{align} .

However, I'm not sure how to generalize this beyond a $3 \times 3$ (for example, a $10 \times 3$). Any guidance would be appreciated.

**

\begin{align}X'X & = \begin{pmatrix} 1 & 1 & \cdots & 1 \\ X_{11} & X_{12} & \cdots & X_{1n} \\ \vdots & \vdots & \ddots & \vdots \\ X_{m1} & X_{m2} & \cdots & X_{mn} \end{pmatrix} \begin{pmatrix} 1 & X_{11} & \cdots & X_{m1} \\ 1 & X_{12} & \cdots & X_{m2} \\ \vdots & \vdots & \ddots & \vdots \\ 1 & X_{1n} & \cdots & X_{mn} \end{pmatrix} \\ & = \begin{pmatrix} \boldsymbol{1}'\boldsymbol{1} & \boldsymbol{1}'\boldsymbol{X_1} & \cdots & \boldsymbol{1}'\boldsymbol{X_m} \\ \boldsymbol{X_1}'\boldsymbol{1} & \boldsymbol{X_1}'\boldsymbol{X_1} & \cdots & \boldsymbol{X_1}'\boldsymbol{X_m}\\ \vdots & \vdots & \ddots & \vdots \\ \boldsymbol{X_m}'\boldsymbol{1} & \boldsymbol{X_m}'\boldsymbol{X_1} & \cdots & \boldsymbol{X_m}'\boldsymbol{X_m} \end{pmatrix}\\ & = \begin{pmatrix} n & 0 & \cdots & 0 \\ 0 & 1 & \cdots & \rho_{1m} \\ \vdots & \vdots & \ddots & \vdots \\ 0 & \rho_{m1} & \cdots & 1 \end{pmatrix} = \begin{pmatrix} n & \boldsymbol{0}' \\ \boldsymbol{0} & \boldsymbol{Q} \end{pmatrix} \end{align}
where $\boldsymbol{Q}$ is the sample correlation matrix.