Howdy,
I'm looking for suggestions on how to compute the Andrews (1991) robust estimator using Mata that I get in Stata by appending vce(hc3) to a regression. Any guidance is greatly appreciated.
As an example, I have computed my White estimator [vce(robust)] using this snippet:
x_vars = st_data(.,("education","experience","exp2"))
cons = J(rows(x_vars),1,1)
X = (x_vars,cons)
y= st_data(.,("wage"))
B_hat=(invsym(X'*X))*(X'*y)
e_hat=y-X*B_hat
sandwich_mid = J(cols(X), cols(X), 0)
n=rows(X)
for (i=1; i<=n; i++) {
sandwich_mid =sandwich_mid+(e_hat[i,1]*X[i,.])'*(e_hat[i,1]*X[i,.])
}
V_robust=(n/(n-cols(X)))*invsym(X'*X)*sandwich_mid*invsym(X'*X)
se_robust=sqrt(diagonal(V_robust))
B_hat
se_robust
Cheers,
Nik
I'm looking for suggestions on how to compute the Andrews (1991) robust estimator using Mata that I get in Stata by appending vce(hc3) to a regression. Any guidance is greatly appreciated.
As an example, I have computed my White estimator [vce(robust)] using this snippet:
x_vars = st_data(.,("education","experience","exp2"))
cons = J(rows(x_vars),1,1)
X = (x_vars,cons)
y= st_data(.,("wage"))
B_hat=(invsym(X'*X))*(X'*y)
e_hat=y-X*B_hat
sandwich_mid = J(cols(X), cols(X), 0)
n=rows(X)
for (i=1; i<=n; i++) {
sandwich_mid =sandwich_mid+(e_hat[i,1]*X[i,.])'*(e_hat[i,1]*X[i,.])
}
V_robust=(n/(n-cols(X)))*invsym(X'*X)*sandwich_mid*invsym(X'*X)
se_robust=sqrt(diagonal(V_robust))
B_hat
se_robust
Cheers,
Nik
Comment