Академический Документы
Профессиональный Документы
Культура Документы
/* Second approach using the mse1 option to get (X'X)^-1 per Stata documentation
P, _robust, Example 1, pg. 446 Stata 14. */
qui reg y d1, mse1
matrix list e(V)
/* above forces mse to be equal to 1, so the variance-covariance matrix
reports 1/SSTx. 1/(4/3)= 3/4= .75 reported above and reconciled to the 4/3
reported as SSTx, approach 1 above. */
matrix V= e(V)
disp 1/V[1,1]
disp sigma/ ((1/V[1,1])^.5)
disp sigma * ((V[1,1])^.5)
/* Calculate SE B1, approach 2 */
matrix drop V
/* Third approach directly using (X'X)^-1 */
gen cons=1
mkmat cons
mkmat d1
matrix x= d1, cons
matrix xprimexinv= inv(x'*x)
matrix list xprimexinv
/* Calculate SE B1, approach 3 */
disp sigma*(xprimexinv[1,1]^.5)
******************************************************************************
/* Calculating the heteroskedasticity robust estimate of the SE for B1 */
**************************************************************************
/* Next drop the i.d. assumption and allow the variance for each
observation to be conditional upon the values of the regressor for that
observation. Below is manual implementation of Huber-White-sandwich estimator
which is [N/N-K](X'X)^-1(Sum: ui^2 xi'xi)(X'X)^-1
See Cameron and Trivedi, Microeconometrics and Baum, An Introduction to
Modern Econometrics Using Stata. Individual estimates of sigma squared
for each observation are obtained. Off diagonal elements are zero. */
reg y d1
predict double uhat, resid
gen uhatsq= uhat^2
/* Create
matrix a=
matrix b=
matrix c=
matrix d=
matrix e=
matrix f=
cons
weig
disp
sigm