代码拉取完成,页面将自动刷新
Mendez C. (2021). Spatial econometrics for cross-sectional data: Columbus crime example. DOI: 10.5281/zenodo.5151076. Notebook available at https://deepnote.com/@carlos-mendez/STATA-Spatial-cross-section-00WMK3sKQl-z6oVRkTQgCQ
* Clean your environment
clear all
macro drop _all
set more off
*cls
*version 17
* Install packages: esttab, estadd, eststo, estout, estpost (http://repec.sowi.unibe.ch/stata/estout/index.html)
* net install st0085_2, from(http://www.stata-journal.com/software/sj14-2)
* ssc install estout, replace
* Import .dta weights matrix with spmatrix (official function from Stata15)
use "https://github.com/quarcs-lab/data-open/raw/master/Columbus/columbus/Wqueen_fromStata_spmat.dta", clear
gen id = _n
order id, first
spset id
spmatrix fromdata WqueenS_fromStata15 = v*, normalize(row) replace
spmatrix summarize WqueenS_fromStata15
Sp dataset: Wqueen_fromStata_spmat.dta Linked shapefile: <none> Data: Cross sectional Spatial-unit ID: _ID (equal to id) Coordinates: <none> Weighting matrix WqueenS_fromStata15 --------------------------------------- Type | contiguity Normalization | row Dimension | 49 x 49 Elements | minimum | 0 minimum > 0 | .1 mean | .0204082 max | .5 Neighbors | minimum | 2 mean | 4.816327 maximum | 10 ---------------------------------------
* Import the dataset and set up the spatial id: https://geodacenter.github.io/data-and-lab/columbus/
use "https://github.com/quarcs-lab/data-open/raw/master/Columbus/columbus/columbusDbase.dta", clear
spset id
Sp dataset: columbusDbase.dta Linked shapefile: <none> Data: Cross sectional Spatial-unit ID: _ID (equal to id) Coordinates: <none>
label var CRIME "Crime"
label var INC "Income"
label var HOVAL "House value"
regress CRIME INC HOVAL
eststo OLS
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
Source | SS df MS Number of obs = 49 -------------+---------------------------------- F(2, 46) = 28.39 Model | 7423.32674 2 3711.66337 Prob > F = 0.0000 Residual | 6014.89274 46 130.758538 R-squared = 0.5524 -------------+---------------------------------- Adj R-squared = 0.5329 Total | 13438.2195 48 279.962906 Root MSE = 11.435 ------------------------------------------------------------------------------ CRIME | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- INC | -1.597311 .3341308 -4.78 0.000 -2.269881 -.9247405 HOVAL | -.2739315 .1031987 -2.65 0.011 -.4816597 -.0662033 _cons | 68.61896 4.735486 14.49 0.000 59.08692 78.151 ------------------------------------------------------------------------------ Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- OLS | 49 -207.0719 -187.3772 3 380.7545 386.4299 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note.
regress CRIME INC HOVAL
estat moran, errorlag(WqueenS_fromStata15)
Source | SS df MS Number of obs = 49 -------------+---------------------------------- F(2, 46) = 28.39 Model | 7423.32674 2 3711.66337 Prob > F = 0.0000 Residual | 6014.89274 46 130.758538 R-squared = 0.5524 -------------+---------------------------------- Adj R-squared = 0.5329 Total | 13438.2195 48 279.962906 Root MSE = 11.435 ------------------------------------------------------------------------------ CRIME | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- INC | -1.597311 .3341308 -4.78 0.000 -2.269881 -.9247405 HOVAL | -.2739315 .1031987 -2.65 0.011 -.4816597 -.0662033 _cons | 68.61896 4.735486 14.49 0.000 59.08692 78.151 ------------------------------------------------------------------------------ Moran test for spatial dependence H0: Error terms are i.i.d. Errorlags: WqueenS_fromStata15 chi2(1) = 5.21 Prob > chi2 = 0.0225
spatwmat using "https://github.com/quarcs-lab/data-open/raw/master/Columbus/columbus/Wqueen_fromStata_spmat.dta", name(WqueenS_fromStata_spatwmat) eigenval(eWqueenS_fromStata_spatwmat) standardize
The following matrices have been created: 1. Imported binary weights matrix WqueenS_fromStata_spatwmat (row-standardized) Dimension: 49x49 2. Eigenvalues matrix eWqueenS_fromStata_spatwmat Dimension: 49x1
quietly reg CRIME INC HOVAL
spatdiag, weights(WqueenS_fromStata_spatwmat)
Diagnostic tests for spatial dependence in OLS regression --------------------------------------------------------- Fitted model ------------------------------------------------------------ CRIME = INC + HOVAL ------------------------------------------------------------ Weights matrix ------------------------------------------------------------ Name: WqueenS_fromStata_spatwmat Type: Imported (binary) Row-standardized: Yes ------------------------------------------------------------ Diagnostics ------------------------------------------------------------ Test | Statistic df p-value -------------------------------+---------------------------- Spatial error: | Moran's I | 2.840 1 0.005 Lagrange multiplier | 5.206 1 0.023 Robust Lagrange multiplier | 0.044 1 0.834 | Spatial lag: | Lagrange multiplier | 8.898 1 0.003 Robust Lagrange multiplier | 3.736 1 0.053 ------------------------------------------------------------
spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15)
eststo SAR
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
estat impact
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Performing grid search ... finished Optimizing concentrated log likelihood: Iteration 0: log likelihood = -182.69106 Iteration 1: log likelihood = -182.67397 Iteration 2: log likelihood = -182.67397 Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -182.67397 Iteration 1: log likelihood = -182.67397 (backed up) Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(3) = 88.00 Prob > chi2 = 0.0000 Log likelihood = -182.67397 Pseudo R2 = 0.5806 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -1.048728 .3304297 -3.17 0.002 -1.696359 -.4010978 HOVAL | -.2663348 .0888474 -3.00 0.003 -.4404725 -.0921971 _cons | 45.60325 7.951826 5.73 0.000 30.01796 61.18854 --------------+---------------------------------------------------------------- WqueenS_fr~15 | CRIME | .4233254 .1255855 3.37 0.001 .1771824 .6694684 --------------+---------------------------------------------------------------- var(e.CRIME)| 96.85718 19.77581 64.91392 144.5193 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(1) = 11.36 Prob > chi2 = 0.0007 Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- SAR | 49 . -182.674 5 375.3479 384.807 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note. progress : 50% 100% Average impacts Number of obs = 49 ------------------------------------------------------------------------------ | Delta-Method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- direct | INC | -1.100895 .3302446 -3.33 0.001 -1.748163 -.4536279 HOVAL | -.2795832 .0935004 -2.99 0.003 -.4628406 -.0963258 -------------+---------------------------------------------------------------- indirect | INC | -.7176833 .3163904 -2.27 0.023 -1.337797 -.0975695 HOVAL | -.1822627 .1083184 -1.68 0.092 -.3945629 .0300375 -------------+---------------------------------------------------------------- total | INC | -1.818579 .5115003 -3.56 0.000 -2.821101 -.8160566 HOVAL | -.4618459 .1818435 -2.54 0.011 -.8182526 -.1054393 ------------------------------------------------------------------------------
spregress CRIME INC HOVAL, ml errorlag(WqueenS_fromStata15)
eststo SEM
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
estat impact
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Performing grid search ... finished Optimizing concentrated log likelihood: Iteration 0: log likelihood = -183.79112 Iteration 1: log likelihood = -183.7495 Iteration 2: log likelihood = -183.74943 Iteration 3: log likelihood = -183.74943 Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -183.74943 Iteration 1: log likelihood = -183.74943 (backed up) Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(2) = 30.15 Prob > chi2 = 0.0000 Log likelihood = -183.74943 Pseudo R2 = 0.5362 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -.9573054 .3771546 -2.54 0.011 -1.696515 -.2180961 HOVAL | -.3045593 .0921607 -3.30 0.001 -.4851909 -.1239276 _cons | 60.27947 5.904297 10.21 0.000 48.70726 71.85168 --------------+---------------------------------------------------------------- WqueenS_fr~15 | e.CRIME | .5467529 .1575357 3.47 0.001 .2379886 .8555173 --------------+---------------------------------------------------------------- var(e.CRIME)| 97.67424 20.43916 64.81252 147.1977 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(1) = 12.05 Prob > chi2 = 0.0005 Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- SEM | 49 . -183.7494 5 377.4989 386.958 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note. progress : 50% 100% Average impacts Number of obs = 49 ------------------------------------------------------------------------------ | Delta-Method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- direct | INC | -.9573054 .3771546 -2.54 0.011 -1.696515 -.2180961 HOVAL | -.3045593 .0921607 -3.30 0.001 -.4851909 -.1239276 -------------+---------------------------------------------------------------- indirect | INC | 0 (omitted) HOVAL | 0 (omitted) -------------+---------------------------------------------------------------- total | INC | -.9573054 .3771546 -2.54 0.011 -1.696515 -.2180961 HOVAL | -.3045593 .0921607 -3.30 0.001 -.4851909 -.1239276 ------------------------------------------------------------------------------
spregress CRIME INC HOVAL, ml ivarlag(WqueenS_fromStata15: INC HOVAL)
eststo SLX
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
estat impact
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -183.9706 Iteration 1: log likelihood = -183.9706 Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(4) = 76.80 Prob > chi2 = 0.0000 Log likelihood = -183.9706 Pseudo R2 = 0.6105 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -1.09739 .3542451 -3.10 0.002 -1.791698 -.4030821 HOVAL | -.2943898 .0963324 -3.06 0.002 -.4831978 -.1055817 _cons | 74.55343 6.363788 11.72 0.000 62.08063 87.02622 --------------+---------------------------------------------------------------- WqueenS_fr~15 | INC | -1.398746 .530778 -2.64 0.008 -2.439051 -.3584399 HOVAL | .214841 .1970276 1.09 0.276 -.171326 .6010079 --------------+---------------------------------------------------------------- var(e.CRIME)| 106.8181 21.5805 71.89125 158.7133 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(2) = 7.31 Prob > chi2 = 0.0259 Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- SLX | 49 . -183.9706 6 379.9412 391.2921 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note. progress : 50% 100% Average impacts Number of obs = 49 ------------------------------------------------------------------------------ | Delta-Method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- direct | INC | -1.09739 .3542451 -3.10 0.002 -1.791698 -.4030821 HOVAL | -.2943898 .0963324 -3.06 0.002 -.4831978 -.1055817 -------------+---------------------------------------------------------------- indirect | INC | -1.398746 .530778 -2.64 0.008 -2.439051 -.3584399 HOVAL | .214841 .1970276 1.09 0.276 -.171326 .6010079 -------------+---------------------------------------------------------------- total | INC | -2.496136 .4671431 -5.34 0.000 -3.411719 -1.580552 HOVAL | -.0795488 .1966064 -0.40 0.686 -.4648903 .3057926 ------------------------------------------------------------------------------
spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15) ivarlag(WqueenS_fromStata15: INC HOVAL)
eststo SDM
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
estat impact
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Performing grid search ... finished Optimizing concentrated log likelihood: Iteration 0: log likelihood = -181.63946 Iteration 1: log likelihood = -181.63926 Iteration 2: log likelihood = -181.63925 Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -181.63925 Iteration 1: log likelihood = -181.63925 (backed up) Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(5) = 93.47 Prob > chi2 = 0.0000 Log likelihood = -181.63925 Pseudo R2 = 0.6120 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -.9199061 .3395439 -2.71 0.007 -1.5854 -.2544122 HOVAL | -.2971294 .0900249 -3.30 0.001 -.473575 -.1206838 _cons | 44.32001 14.18338 3.12 0.002 16.5211 72.11892 --------------+---------------------------------------------------------------- WqueenS_fr~15 | INC | -.5839133 .6053402 -0.96 0.335 -1.770358 .6025317 HOVAL | .2576843 .1850135 1.39 0.164 -.1049356 .6203042 CRIME | .4034626 .1718368 2.35 0.019 .0666687 .7402564 --------------+---------------------------------------------------------------- var(e.CRIME)| 93.27224 19.17105 62.34442 139.5427 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(3) = 13.88 Prob > chi2 = 0.0031 Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- SDM | 49 . -181.6393 7 377.2785 390.5213 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note. progress : 50% 100% Average impacts Number of obs = 49 ------------------------------------------------------------------------------ | Delta-Method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- direct | INC | -1.024988 .3241534 -3.16 0.002 -1.660317 -.3896588 HOVAL | -.2819673 .0911938 -3.09 0.002 -.4607038 -.1032309 -------------+---------------------------------------------------------------- indirect | INC | -1.495926 .6979787 -2.14 0.032 -2.863939 -.1279129 HOVAL | .215844 .2797595 0.77 0.440 -.3324746 .7641626 -------------+---------------------------------------------------------------- total | INC | -2.520914 .7319696 -3.44 0.001 -3.955548 -1.08628 HOVAL | -.0661233 .308123 -0.21 0.830 -.6700333 .5377866 ------------------------------------------------------------------------------
spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15) ivarlag(WqueenS_fromStata15: INC HOVAL)
* Wald test: Reduce to OLS? (NO if p < 0.05 of the spatial terms)
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Performing grid search ... finished Optimizing concentrated log likelihood: Iteration 0: log likelihood = -181.63946 Iteration 1: log likelihood = -181.63926 Iteration 2: log likelihood = -181.63925 Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -181.63925 Iteration 1: log likelihood = -181.63925 (backed up) Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(5) = 93.47 Prob > chi2 = 0.0000 Log likelihood = -181.63925 Pseudo R2 = 0.6120 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -.9199061 .3395439 -2.71 0.007 -1.5854 -.2544122 HOVAL | -.2971294 .0900249 -3.30 0.001 -.473575 -.1206838 _cons | 44.32001 14.18338 3.12 0.002 16.5211 72.11892 --------------+---------------------------------------------------------------- WqueenS_fr~15 | INC | -.5839133 .6053402 -0.96 0.335 -1.770358 .6025317 HOVAL | .2576843 .1850135 1.39 0.164 -.1049356 .6203042 CRIME | .4034626 .1718368 2.35 0.019 .0666687 .7402564 --------------+---------------------------------------------------------------- var(e.CRIME)| 93.27224 19.17105 62.34442 139.5427 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(3) = 13.88 Prob > chi2 = 0.0031
* Wald test: Reduce to SLX? (NO if p < 0.05)
test ([WqueenS_fromStata15]CRIME = 0)
( 1) [WqueenS_fromStata15]CRIME = 0 chi2( 1) = 5.51 Prob > chi2 = 0.0189
* Wald test: Reduce to SAR? (NO if p < 0.05)
test ([WqueenS_fromStata15]INC = 0) ([WqueenS_fromStata15]HOVAL = 0)
( 1) [WqueenS_fromStata15]INC = 0 ( 2) [WqueenS_fromStata15]HOVAL = 0 chi2( 2) = 2.10 Prob > chi2 = 0.3494
* Wald test: Reduce to SEM? (NO if p < 0.05)
testnl ([WqueenS_fromStata15]INC = -[WqueenS_fromStata15]CRIME*[CRIME]INC) ([WqueenS_fromStata15]HOVAL = -[WqueenS_fromStata15]CRIME*[CRIME]HOVAL)
(1) [WqueenS_fromStata15]INC = -[WqueenS_fromStata15]CRIME*[CRIME]INC (2) [WqueenS_fromStata15]HOVAL = -[WqueenS_fromStata15]CRIME*[CRIME]HOVAL chi2(2) = 4.08 Prob > chi2 = 0.1300
spregress CRIME INC HOVAL, ml ivarlag(WqueenS_fromStata15: INC HOVAL) errorlag(WqueenS_fromStata15)
eststo SDEM
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
estat impact
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Performing grid search ... finished Optimizing concentrated log likelihood: Iteration 0: log likelihood = -181.7792 Iteration 1: log likelihood = -181.779 Iteration 2: log likelihood = -181.779 Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -181.779 Iteration 1: log likelihood = -181.779 (backed up) Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(4) = 46.68 Prob > chi2 = 0.0000 Log likelihood = -181.779 Pseudo R2 = 0.6092 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -1.052259 .3233005 -3.25 0.001 -1.685916 -.4186011 HOVAL | -.2781741 .091165 -3.05 0.002 -.4568542 -.099494 _cons | 73.64508 8.761175 8.41 0.000 56.4735 90.81667 --------------+---------------------------------------------------------------- WqueenS_fr~15 | INC | -1.204876 .5860084 -2.06 0.040 -2.353431 -.0563208 HOVAL | .1312451 .2111476 0.62 0.534 -.2825966 .5450868 e.CRIME | .4035821 .1773581 2.28 0.023 .0559666 .7511976 --------------+---------------------------------------------------------------- var(e.CRIME)| 93.8033 19.30177 62.67113 140.4005 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(3) = 12.03 Prob > chi2 = 0.0073 Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- SDEM | 49 . -181.779 7 377.558 390.8007 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note. progress : 50% 100% Average impacts Number of obs = 49 ------------------------------------------------------------------------------ | Delta-Method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- direct | INC | -1.052259 .3233005 -3.25 0.001 -1.685916 -.4186011 HOVAL | -.2781741 .091165 -3.05 0.002 -.4568542 -.099494 -------------+---------------------------------------------------------------- indirect | INC | -1.204876 .5860084 -2.06 0.040 -2.353431 -.0563208 HOVAL | .1312451 .2111476 0.62 0.534 -.2825966 .5450868 -------------+---------------------------------------------------------------- total | INC | -2.257135 .6515178 -3.46 0.001 -3.534086 -.9801833 HOVAL | -.146929 .2403654 -0.61 0.541 -.6180365 .3241785 ------------------------------------------------------------------------------
spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15) errorlag(WqueenS_fromStata15)
eststo SAC
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
estat impact
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Performing grid search ... finished Optimizing concentrated log likelihood: Iteration 0: log likelihood = -182.57166 Iteration 1: log likelihood = -182.55505 Iteration 2: log likelihood = -182.55502 Iteration 3: log likelihood = -182.55502 Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -182.55502 Iteration 1: log likelihood = -182.55502 (backed up) Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(3) = 57.82 Prob > chi2 = 0.0000 Log likelihood = -182.55502 Pseudo R2 = 0.5793 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -1.042749 .3357121 -3.11 0.002 -1.700733 -.3847656 HOVAL | -.2798409 .09405 -2.98 0.003 -.4641755 -.0955063 _cons | 47.91536 9.298756 5.15 0.000 29.69013 66.14058 --------------+---------------------------------------------------------------- WqueenS_fr~15 | CRIME | .3693743 .1792524 2.06 0.039 .0180459 .7207026 e.CRIME | .1464169 .2997182 0.49 0.625 -.44102 .7338538 --------------+---------------------------------------------------------------- var(e.CRIME)| 97.04344 19.77021 65.09608 144.6697 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(2) = 10.63 Prob > chi2 = 0.0049 Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- SAC | 49 . -182.555 6 377.11 388.461 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note. progress : 50% 100% Average impacts Number of obs = 49 ------------------------------------------------------------------------------ | Delta-Method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- direct | INC | -1.080454 .3399105 -3.18 0.001 -1.746666 -.4142414 HOVAL | -.2899596 .0958282 -3.03 0.002 -.4777794 -.1021397 -------------+---------------------------------------------------------------- indirect | INC | -.5730615 .4220918 -1.36 0.175 -1.400346 .2542232 HOVAL | -.1537916 .1161114 -1.32 0.185 -.3813657 .0737826 -------------+---------------------------------------------------------------- total | INC | -1.653515 .6169502 -2.68 0.007 -2.862715 -.4443151 HOVAL | -.4437511 .1749537 -2.54 0.011 -.7866542 -.1008481 ------------------------------------------------------------------------------
spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15) ivarlag(WqueenS_fromStata15: INC HOVAL) errorlag(WqueenS_fromStata15)
eststo GNS
estat ic
mat s=r(S)
quietly estadd scalar AIC = s[1,5]
estat impact
(49 observations) (49 observations (places) used) (weighting matrix defines 49 places) Performing grid search ... finished Optimizing concentrated log likelihood: Iteration 0: log likelihood = -181.60541 Iteration 1: log likelihood = -181.58046 Iteration 2: log likelihood = -181.58014 Iteration 3: log likelihood = -181.58014 Optimizing unconcentrated log likelihood: Iteration 0: log likelihood = -181.58014 Iteration 1: log likelihood = -181.58014 (backed up) Spatial autoregressive model Number of obs = 49 Maximum likelihood estimates Wald chi2(5) = 62.57 Prob > chi2 = 0.0000 Log likelihood = -181.58014 Pseudo R2 = 0.6115 ------------------------------------------------------------------------------- CRIME | Coefficient Std. err. z P>|z| [95% conf. interval] --------------+---------------------------------------------------------------- CRIME | INC | -.9587964 .3565186 -2.69 0.007 -1.65756 -.2600328 HOVAL | -.2890341 .0924525 -3.13 0.002 -.4702378 -.1078305 _cons | 53.04797 31.4573 1.69 0.092 -8.607201 114.7031 --------------+---------------------------------------------------------------- WqueenS_fr~15 | INC | -.7734089 .8571065 -0.90 0.367 -2.453307 .906489 HOVAL | .2184638 .2304209 0.95 0.343 -.2331529 .6700806 CRIME | .284377 .4183839 0.68 0.497 -.5356404 1.104394 e.CRIME | .1632527 .4661928 0.35 0.726 -.7504684 1.076974 --------------+---------------------------------------------------------------- var(e.CRIME)| 94.48532 19.32815 63.27621 141.0874 ------------------------------------------------------------------------------- Wald test of spatial terms: chi2(4) = 12.51 Prob > chi2 = 0.0139 Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- GNS | 49 . -181.5801 8 379.1603 394.2948 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] BIC note. progress : 50% 100% Average impacts Number of obs = 49 ------------------------------------------------------------------------------ | Delta-Method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- direct | INC | -1.032865 .3233102 -3.19 0.001 -1.666541 -.3991884 HOVAL | -.2793854 .091442 -3.06 0.002 -.4586084 -.1001624 -------------+---------------------------------------------------------------- indirect | INC | -1.387691 .7255571 -1.91 0.056 -2.809757 .0343749 HOVAL | .1807716 .2720029 0.66 0.506 -.3523444 .7138875 -------------+---------------------------------------------------------------- total | INC | -2.420556 .7598804 -3.19 0.001 -3.909894 -.9312175 HOVAL | -.0986138 .2989642 -0.33 0.742 -.6845729 .4873452 ------------------------------------------------------------------------------
%html
esttab OLS SAR SEM SLX SDM SDEM SAC GNS, label stats(AIC) mtitle("OLS" "SAR" "SEM" "SLX" "SDM" "SDEM" "SAC" "GNS") html
(1) | (2) | (3) | (4) | (5) | (6) | (7) | (8) | |
OLS | SAR | SEM | SLX | SDM | SDEM | SAC | GNS | |
main | ||||||||
Income | -1.597*** | -1.049** | -0.957* | -1.097** | -0.920** | -1.052** | -1.043** | -0.959** |
(-4.78) | (-3.17) | (-2.54) | (-3.10) | (-2.71) | (-3.25) | (-3.11) | (-2.69) | |
House value | -0.274* | -0.266** | -0.305*** | -0.294** | -0.297*** | -0.278** | -0.280** | -0.289** |
(-2.65) | (-3.00) | (-3.30) | (-3.06) | (-3.30) | (-3.05) | (-2.98) | (-3.13) | |
Constant | 68.62*** | 45.60*** | 60.28*** | 74.55*** | 44.32** | 73.65*** | 47.92*** | 53.05 |
(14.49) | (5.73) | (10.21) | (11.72) | (3.12) | (8.41) | (5.15) | (1.69) | |
WqueenS_fromStata15 | ||||||||
Crime | 0.423*** | 0.403* | 0.369* | 0.284 | ||||
(3.37) | (2.35) | (2.06) | (0.68) | |||||
e.Crime | 0.547*** | 0.404* | 0.146 | 0.163 | ||||
(3.47) | (2.28) | (0.49) | (0.35) | |||||
Income | -1.399** | -0.584 | -1.205* | -0.773 | ||||
(-2.64) | (-0.96) | (-2.06) | (-0.90) | |||||
House value | 0.215 | 0.258 | 0.131 | 0.218 | ||||
(1.09) | (1.39) | (0.62) | (0.95) | |||||
/ | ||||||||
var(e.CRIME) | 96.86*** | 97.67*** | 106.8*** | 93.27*** | 93.80*** | 97.04*** | 94.49*** | |
(4.90) | (4.78) | (4.95) | (4.87) | (4.86) | (4.91) | (4.89) | ||
AIC | 380.8 | 375.3 | 377.5 | 379.9 | 377.3 | 377.6 | 377.1 | 379.2 |
t statistics in parentheses
* p < 0.05, ** p < 0.01, *** p < 0.001 |
eststo clear
The following comparison requires Stata 17. Caution is needed as the p-values are not shown
collect clear
quietly spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15)
collect: quietly estat impact
quietly spregress CRIME INC HOVAL, ml ivarlag(WqueenS_fromStata15: INC HOVAL)
collect: quietly estat impact
quietly spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15) ivarlag(WqueenS_fromStata15: INC HOVAL)
collect: quietly estat impact
quietly spregress CRIME INC HOVAL, ml ivarlag(WqueenS_fromStata15: INC HOVAL) errorlag(WqueenS_fromStata15)
collect: quietly estat impact
quietly spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15) errorlag(WqueenS_fromStata15)
collect: quietly estat impact
quietly spregress CRIME INC HOVAL, ml dvarlag(WqueenS_fromStata15) ivarlag(WqueenS_fromStata15: INC HOVAL) errorlag(WqueenS_fromStata15)
collect: quietly estat impact
collect label list cmdset, all
collect style autolevels result b_direct b_indirect
collect label levels cmdset 1 "SAR" 2 "SLX" 3 "SDM" 4 "SDEM" 5 "SAC" 6 "GNS"
collect style cell, nformat(%7.2f)
collect layout (colname#result) (cmdset)
Collection: default Dimension: cmdset Label: Command results index Level labels: 1 2 3 4 5 6 Collection: default Rows: colname#result Columns: cmdset Table 1: 6 x 6 -------------------------------------------------- | SAR SLX SDM SDEM SAC GNS -------------+------------------------------------ Income | b_direct | -1.10 -1.10 -1.02 -1.05 -1.08 -1.03 b_indirect | -0.72 -1.40 -1.50 -1.20 -0.57 -1.39 House value | b_direct | -0.28 -0.29 -0.28 -0.28 -0.29 -0.28 b_indirect | -0.18 0.21 0.22 0.13 -0.15 0.18 --------------------------------------------------
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。