Computing an influence matrix

51 Views Asked by At

I am struggling with the computation of a hat matrix. Indeed, I have built a model where I have a predicted values ($\hat{y}$) as a function of measured values ($y$) like this:

$$\hat{y} = H y$$

In this case, a simple model could be $H = X(X^TX)^{-1}X^T$ (from the least squares theory)

However, I am looking to "solve" the inverse problem and find $H$ without knowing $X$. Therefore, assuming I only have the results from the model and their measures ($\hat{y}$ and $y$).

From wikipedia, I have found this article Projection matrix, where $H$ is computed from the covariance and variance of $\hat{y}$ and $y$ with the following expression:

$$h_{ij}=\frac{Cov(\hat{y}_i,y_j)}{Var(y_j)}$$

However, $\hat{y}$ and $y$ are of size "n", $H$ should be of size nxn and $Cov(\hat{y},y)$ isa 2x2 matrix, or I am doing something wrong. Could someone be so gentle to give me an application example or detailing the computation of $h_{ij}$ please?