# Calculating leverage/cook's distance for a Weighted Spatial Simultaneous Autoregression Model

I am estimating a Weighted Spatial Simultaneous Autoregression Model (spdep::spautolm --> Link) in R and I would like to do some residual analysis.

Unfortunately functions such as hatvalues,cooks.distance or plot.lm do not work for spautolm objects. Yet, I would like to calculate leverages and cook distances for my model (see also my post on stackoverflow).

My Model looks like this:

$Y = X^T\beta + \lambda W(Y − X^T\beta)+ \epsilon$ with $\epsilon\sim^{iid} N(0,\sigma^2)$

Thus:

$Var[Y]=\Sigma_{SAR} = \sigma²(I-\lambda W)^{-1}V(I-\lambda W)^{-1}$ with $V=diag[1/n_i]$

$\rho$ is my spatial autoregression parameter and $W$ the matrix that represents spatial dependence.

Obviously, a simple calculation of the hatmatrix $H$ via $H=X(X^TX)^{-1}X^T$ is not valid here due to the weighting and the modeled spatial autocorrelation.

Any ideas how to calculate the leverages and cook's distances by hand in R for this model?