# Matrix regression: Prove H1=1 (H=hat matrix)

#### Patrick Yan

##### New Member
I couldn't find a way to prove this...

Prove H1=1

(H=hat matrix; 1=column vector of n 1s)

I thought that it's "obvious" since the projection of the vector 1 onto the space spanned by the columns of design matrix X is clearly vector 1, but I need to prove it for real.

#### Dason

You definitely forgot to include some details here because the hat matrix isn't always 1.

#### Patrick Yan

##### New Member
Well it's the Hat matrix multiplied by the One vector equals the One vector. I wish there was some other details...

#### Dason

What do they tell you about the design matrix? Cause if they don't say anything you could disprove it.

#### Patrick Yan

##### New Member
Yeah, we learned that the design matrix is [1 X_1 X_2 ... X_p-1] where X_i's are column vectors of input variables.

#### Dason

Ok so you're assuming that that there is a column of 1s at the beginning. This doesn't have to be the case but if we're assuming that it's the case then it makes it a little easier. What have you learning about the hat matrix? How much linear algebra do you know? Do you know how to take the design matrix and construct the hat matrix?

#### BGM

##### TS Contributor
One property the vector $$\mathbf{1} \in \text{col}(X)$$ because

$$\begin{bmatrix} \mathbf{1} && \mathbf{X}_1 && \cdots && \mathbf{X}_{p-1} \end{bmatrix} \begin{bmatrix} 1 \\ 0 \\ \vdots \\ 0 \end{bmatrix} = \mathbf{1}$$

In short, we have the relationship $$X\mathbf{e}_1 = \mathbf{1}$$ and a direct substitution in the definition of hat matrix can yield the desired result.

#### Patrick Yan

##### New Member
@Dason: I am learning linear algebra as I learn regression. I know the hat matrix = X(XX)^-1X where  means transpose.

@BGM: Would this be a valid solution?:

X (XX)^-1 (X`X) e_1
= X I e_1
= 1

#### Dason

You would probably want to start it with H1 = HXe_1 = ... and then put what you have. I'm guessing we're assuming that X is full column rank in which case all of this works out fine.

#### Patrick Yan

##### New Member
Yep, thanks a lot! Matrix algebra is quite confusing to me