Computation of the standard error of a FGLS coefficient estimate

2 visualizzazioni (ultimi 30 giorni)
Hi,
I use the MATLAB code below to calculate the standard errors of the coeffficients estimated by Weighted Least Squares (WLS), using some data at hand. I wanted to check if my calculation is correct. Therefore I used Stata, an econoemtric software, which computes the standard errors of WLS coefficients estimates. Stata documentation at http://www.stata.com/manuals13/rvwls.pdf gives the formula used by Stata. The coefficient estimates I obtain in MATLAB are exactly the same coefficient estimates I obtain in Stata, but the standard errors differ. In particular, the standard errors I obtain in MATLAB are always a constant fraction of those I obtain in Stata. That is, the former figures are always about half the size of the latter figures. I am surprised because the formula of the WLS coefficient estimates is (X'*inv(Omega)*X)\(X'*inv(Omega)*Y) and it is straightforward to obtain the variance-covariance matrix of the WLS coefficient estimates, which is just the inverse of (X'*inv(Omega)*X). I cannot seem to pinpoint the reason why the standard errors differ.
Tunga
  • Matlab code
clear;
load 'data';
Y = unaid;
N = length(Y);
X = [ones(N,1) dur ncb rank year];
beta_hat = (X'*X)\(X'*Y);
yhat = X*beta_hat;
e = Y-yhat;
log_e2 = log(e.^2);
beta_hat2 = (X'*X)\(X'*log_e2);
yhat2 = X*beta_hat2;
O = diag(exp(yhat2));
OI = eye(N)/O;
beta_hat_fgls = (X'*OI*X)\(X'*OI*Y);
beta_hat_varcov_fgls = (X'*OI*X)\eye(5);
beta_hat_se_fgls = sqrt(diag(beta_hat_varcov_fgls));
Standard errors of five variables:
2.087
0.013
0.044
0.025
0.024
  • Stata code
clear all
use "data", clear
reg unaid dur ncb rank year
predict e, resid
gen e2 = e^2
gen le = log(e2)
reg le dur ncb rank year
predict le_hat
gen w_hat = (exp(le_hat))
reg unaid dur ncb rank year [aweight=1/w_hat]
Standard errors of five variables:
3.883
0.025
0.081
0.048
0.044

Risposte (0)

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by