Hi all!
I'm trying to compute the jackknife variance estimate using the formula from Hansen's "Econometrics" (P259) as below (I know I can use "jackknife" command directly but the professor ask to compute and then compare with the result from "jackknife" command):
Array

I use "forvalues" to form a loop to get the value of all hii (in my code: hi), and I want to further calculate the residual with a tilt on the head. However, when I use a new loop to get e_tilt for each observation i, it says
Code:
conformability error
. I suppose it is because my hii is in old loop so I cannot use it in the new loop. So I'm thinking of creating a new matrix and store each hii into the matrix, what command should I use? And is there any other way that can use the hii directly?
My code is attached below, where x is my regressor(only one) generated from a standard normal distribution, h`i' is hii , e_hat is the residual generated by "predict y, residuals".
Thank you so much!

Code:
//create X'X from sample
mat accum xprimex = x
mat li xprimex
//generate hii or each observation
forvalues i = 1(1)100 {
        mat matx`i' = matx[`i', 1]
        mat h`i' = matx`i''*xprimex*matx`i' //here xi is scalar
        mat li h`i'
       }


//e_tilt = inv(1-hi)*e_hat
mkmat ehat, matrix(mehat)
mat li mehat
forvalues i = 1(1)100{
        mat mehat`i' = mehat[`i',1]
        mat e_tilt`i' = ((1-h`i')^(-1))*mehat`i'
        *mat li e_tilta`i'
        }