I'm stuck learning the hat matrix and wondered if someone could help with a question. If I have the model $$Y_i =\beta_0+\beta_1X_i+\epsilon_i,i = 1,2,3 \dots n,$$ how can I calculate the hat matrix as
$$H = X(X^\prime X)^{-1}X^\prime$$
And what would the $h_{ij}$ element be?
modin R you would write something like:X = model.matrix(mod); (H = (X %*% solve(crossprod(X)) %*% t(X))). See this thread here for more details. – usεr11852 Oct 28 '15 at 21:42