hacSE#

Purpose#

Procedure to compute the Newey-West HAC robust standard errors.

Format#

vce_hac = hacSE(x, resid[, constant, nwtrunc, ss])#
vce_hac = hacSE(dataset, formula, resid[, constant, nwtrunc, ss])
vce_hac = hacSE(dataframe, formula, resid[, constant, nwtrunc, ss])
Parameters:
  • x (NxK matrix) – independent regression variables, should not include a const.

  • resid (NTx1 matrix) –

    ols residuals.

    Note

    if using olsmt() these are stored in the olsOut structure member resid.

  • dataset (string) – name of dataset.

  • formula (String) – formula string of the independent variables. E.g "X1 + X2", ‘X1’ and ‘X2’ are names of independent variables;

  • constant – Optional input, indicator variable for including a const. 1 for including a const, 0 for no const. Default = 1.

  • nwtrunc (Scalar) – Optional input, scalar, the Newey-West iteration constant. Set to 0 to have GAUSS use Newey and West’s the suggested number of iterations, 4(T/100)^2/9 where T is the number of observations. Default = 0;

  • ss (Scalar) – Optional input, indicator variable for using the small sample correction. 1 to compute the small sample correction, 0 for no correction. Default = 1.

Returns:

vce_hac (KxK matrix) – Newey-West HAC-robust variance-covariance matrix.

Examples#

new;

// Load data using auto dataset
fname = getGAUSSHome("examples/regsmpl.dta");
data = loadd(fname);

// Control structure
struct olsmtControl o_ctl;
o_ctl = olsmtControlCreate();

// Turn on to estimate residuals
o_ctl.res = 1;

// Declare output structure
struct olsmtOut o_out;

// Run initial ols
o_out = olsmt(fname, "ln_wage ~ age + age:age + tenure", o_ctl);

This estimates the OLS regression and finds the i.i.d. standard errors:

Valid cases:                 28101      Dependent variable:             ln_wage
Missing cases:                 433      Deletion method:               Listwise
Total SS:                 6414.965      Degrees of freedom:               28097
R-squared:                   0.164      Rbar-squared:                     0.164
Residual SS:              5360.440      Std error of est:                 0.437
F(3,28097):               1842.448      Probability of F:                 0.000
Durbin-Watson:               0.906

                         Standard                 Prob   Standardized  Cor with
Variable     Estimate      Error      t-value     >|t|     Estimate    Dep Var
-------------------------------------------------------------------------------

const        0.333982    0.050441    6.621206     0.000       ---         ---
age          0.075217    0.003474   21.653863     0.000    1.054270    0.278922
age:age     -0.001085    0.000058  -18.862899     0.000   -0.916788    0.265497
tenure       0.039088    0.000774   50.479037     0.000    0.306895    0.370584

Calling hacrSE() estimates the HAC-robust standard errors:

// Find HAC-robust standard errors regression includes const
vce_hac = hacse(fname, "age + age:age + tenure", o_out.resid );

The resulting standard errors are:

        VARIABLE           HAC SE
-------------------------------------

           const         0.066368
             age        0.0047206
         age:age       8.0260e-05
          tenure        0.0013722
-------------------------------------

See also

Functions olsmt(), robustSE(), clusterSE()