

marksample touse // indicator for inclusion in the sampleĮreturn post beta V_spatial_HAC, esample(touse)ĭisp as txt "SE CORRECTED FOR CROSS-SECTIONAL SPATIAL DEPENDANCE "ĭisp as txt " AND PANEL-SPECIFIC SERIAL CORRELATION "ĭisp as txt "INDEPENDANT VARIABLES: `X' "ĭisp as txt "INSTRUMENTED VARIABLES: `endog' "ĭisp as txt "INSTRUMENTAL VARIABLES: `exog' "ĭisp as txt "SPATIAL CORRELATION KERNAL CUTOFF: `distcutoff' KM "ĭisp as txt "(NOTE: LINEAR BARTLETT WINDOW USED FOR SPATIAL KERNAL) "ĭisp as txt "SERIAL CORRELATION KERNAL CUTOFF: `lagcutoff' PERIODS "Įreturn display // standard Stata regression table format V = invZX * ZeeZ_spatial_HAC * invZX' / n generate the VCE for x-sectional spatial correlation and serial correlation step b: construct Z'e'eZ for given observation Window_t = window_t : * (time1 : ! = time1) double counted (since they were counted once above for the spatial this is required so diagonal terms in var-covar matrix are not Window_t = (abs(time1: - time1) : < = lag_cutoff) : * weight Npanel = rows(panelUnique) // # of panels *-FOURTH, CORRECT VCE FOR SERIAL CORR- */ storing these estimates for comparison to OLS and the HAC estimates then filling back in all the parameters for postestimationĮreturn local title = "Linear regression "Įreturn local estat_cmd = "regress_estat " this sets the new estimates as the most recent modelĮreturn post beta V_spatial, esample(`touse') the row and column names of the new VCE must match the vector b

storing old statistics about the estimate so postestimation can be used in theory, it should be already, but it may not be due to rounding errors for large datasets generate the VCE for only cross-sectional spatial correlation, add each new k x k matrix onto the existing matrix (will be symmetric) note that without instruments, this will be the same as X'e'eX step b: construct Z'e'eZ for the given observation

this weights observations as a linear function of distance Star: same as display, but uses stars to denote significance and does not show SE & t-stat. Pvar: variable containing panel variable (must be numeric, see "encode")ĭistcutoff(#): display a table with estimated coeff and SE & t-stat using OLS, adjusting for spatial correlation and adjusting for both spatial and serial correlation. Latvar: variable containing latitude in DEGREES of each obs Xvarlist: independnet variables (INCLUDE constant as column) Ols_spatial_HAC dep indep*, lat(C1) lon(C2) timevar(year) panelvar(id) dist(100) lag(2) star dropvar Ols_spatial_HAC dep indep1 indep2 const, lat(C1) lon(C2) t(year) p(id) dist(300) lag(3) bartlett disp

Var-CovarĪ variable equal to 1 is required to estimate a constant term. Given individual over multiple periods up to some lag length. Ols_spatial_HAC Yvar Xvarlist (ENDGvariable = EXGvarlist), lat(latvar) lon(lonvar) Timevar(tvar) Panelvar(pvar) įunction calculates non-parametric (GMM) spatial and autocorrelation
#Geodist install stata update#
V4 UPDATE 3/20 THE OPTION OF INSTRUMENTAL VARIABLE REGRESSION AND ADDED WEIGHTS SIGN OF BIAS IN V2 IS INDETERMINATE, DEPENDS ON LAG LENGTH AND DATA V3 UPDATE 6/18 ERROR (LINE 428) FOUND BY MATHIAS THOENIG THAT INCORRECTLYĬOMPUTED WEIGHTS FOR INTER-TEMPORAL AUTOCORRELATION ESTIMATES WITHIN PANEL
#Geodist install stata code#
HSIANG 6/10 UPDATE 6/13 'DROPVAR' OPTION BASED ON CODE PROVIDED BY KYLE MENG HSIANG 6/2010: PROGRAM TO ESTIMATE SPATIAL HAC ERRORS FOR OLS REGRESSION MODEL
