home workflow spillover spmatrix spregress spxtregress

About option -force-


Missing values problem

Suppose we have fitted a basic SAR model using spregress, and everything is fine. Then we want to add another covariate $x$ to our basic model, but $x$ contains some missing value in certain observations.

. use texas, clear
(S.Messner et al.(2000), U.S southern county homicide rates in 1990)

. spmatrix create contiguity W, replace

.                                                 //  basic model
. spregress hrate gini, dvarlag(W) gs2sls
  (254 observations)
  (254 observations (places) used)
  (weighting matrix defines 254 places)

Spatial autoregressive model                    Number of obs     =        254
GS2SLS estimates                                Wald chi2(2)      =      11.12
                                                Prob > chi2       =     0.0038
                                                Pseudo R2         =     0.0419

------------------------------------------------------------------------------
       hrate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
hrate        |
        gini |   46.40451   14.15305     3.28   0.001     18.66504    74.14398
       _cons |  -10.42408   5.657206    -1.84   0.065      -21.512    .6638364
-------------+----------------------------------------------------------------
W            |
       hrate |   .0010684   .2164789     0.00   0.996    -.4232223    .4253592
------------------------------------------------------------------------------
Wald test of spatial terms:          chi2(1) = 0.00       Prob > chi2 = 0.9961

.                                                 //  add x, which contains
.                                                 //  missing values
. gen x   = rnormal(0,1) if gin< 0.45
(21 missing values generated)

. cap noi spregress hrate gini x, dvarlag(W) gs2sls
  (254 observations)
  (21 observations excluded due to missing values)
  (233 observations (places) used)
  (weighting matrix defines 254 places)
weighting matrix defines places not in estimation sample
    Excluding observations excludes the spillovers from those observations to
    other observations which are not excluded. You must determine whether
    this is appropriate in this case and, if it is, specify option force.

esample and weighting matrix

Problem Solution Example
esample $\supseteq$ W
  • restrict esample use if and in
  • create bigger W
Example 1
esample $\subseteq$ W
  • make esample bigger
  • use option force
Example 2

Example 1

. use texas, clear
(S.Messner et al.(2000), U.S southern county homicide rates in 1990)

. spmatrix create contiguity W in 1/100, replace

. /*
>         Problem : esample > W
> */
. cap noi spregress hrate gini, dvarlag(W) gs2sls
  (254 observations)
  (254 observations (places) used)
  (weighting matrix defines 100 places)
estimation sample defines places not in weighting matrix
    You must specify if or in to restrict the estimation sample to the places
    in the weighting matrix or use a different weighting matrix.

. /*
>         Solution 1 : restrict esample using if and in
> */
. spregress hrate gini in 1/100, dvarlag(W) gs2sls
  (254 observations)
  (154 observations excluded due to if/in)
  (100 observations (places) used)
  (weighting matrix defines 100 places)

Spatial autoregressive model                    Number of obs     =        100
GS2SLS estimates                                Wald chi2(2)      =       1.91
                                                Prob > chi2       =     0.3845
                                                Pseudo R2         =     0.0126

------------------------------------------------------------------------------
       hrate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
hrate        |
        gini |   5.476528   27.13021     0.20   0.840     -47.6977    58.65075
       _cons |   7.729059   11.38011     0.68   0.497    -14.57554    30.03366
-------------+----------------------------------------------------------------
W            |
       hrate |  -.4645531   .3635528    -1.28   0.201    -1.177104    .2479973
------------------------------------------------------------------------------
Wald test of spatial terms:          chi2(1) = 1.63       Prob > chi2 = 0.2013

. /*
>         Solution 2 : create bigger W
> */
. spmatrix create contiguity W, replace

. spregress hrate gini, dvarlag(W) gs2sls
  (254 observations)
  (254 observations (places) used)
  (weighting matrix defines 254 places)

Spatial autoregressive model                    Number of obs     =        254
GS2SLS estimates                                Wald chi2(2)      =      11.12
                                                Prob > chi2       =     0.0038
                                                Pseudo R2         =     0.0419

------------------------------------------------------------------------------
       hrate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
hrate        |
        gini |   46.40451   14.15305     3.28   0.001     18.66504    74.14398
       _cons |  -10.42408   5.657206    -1.84   0.065      -21.512    .6638364
-------------+----------------------------------------------------------------
W            |
       hrate |   .0010684   .2164789     0.00   0.996    -.4232223    .4253592
------------------------------------------------------------------------------
Wald test of spatial terms:          chi2(1) = 0.00       Prob > chi2 = 0.9961

Example 2

. use texas, clear
(S.Messner et al.(2000), U.S southern county homicide rates in 1990)

. spmatrix create contiguity W, replace

. /*
>         Problem : esample < W
> */
. cap noi spregress hrate gini in 1/100, dvarlag(W) gs2sls
  (254 observations)
  (154 observations excluded due to if/in)
  (100 observations (places) used)
  (weighting matrix defines 254 places)
weighting matrix defines places not in estimation sample
    Excluding observations excludes the spillovers from those observations to
    other observations which are not excluded. You must determine whether
    this is appropriate in this case and, if it is, specify option force.

. /*
>         Solution 1 : make esample bigger
> */
. spregress hrate gini, dvarlag(W) gs2sls
  (254 observations)
  (254 observations (places) used)
  (weighting matrix defines 254 places)

Spatial autoregressive model                    Number of obs     =        254
GS2SLS estimates                                Wald chi2(2)      =      11.12
                                                Prob > chi2       =     0.0038
                                                Pseudo R2         =     0.0419

------------------------------------------------------------------------------
       hrate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
hrate        |
        gini |   46.40451   14.15305     3.28   0.001     18.66504    74.14398
       _cons |  -10.42408   5.657206    -1.84   0.065      -21.512    .6638364
-------------+----------------------------------------------------------------
W            |
       hrate |   .0010684   .2164789     0.00   0.996    -.4232223    .4253592
------------------------------------------------------------------------------
Wald test of spatial terms:          chi2(1) = 0.00       Prob > chi2 = 0.9961

. /*
>         Solution 2 : force option
> */
. spregress hrate gini in 1/100, dvarlag(W) gs2sls force
  (254 observations)
  (154 observations excluded due to if/in)
  (100 observations (places) used)
  (weighting matrix defines 254 places)
  (you specified -force-)
  (weighting matrix matched 100 places in data)
  (weighting matrix W_s001 created)

Spatial autoregressive model                    Number of obs     =        100
GS2SLS estimates                                Wald chi2(2)      =       1.91
                                                Prob > chi2       =     0.3845
                                                Pseudo R2         =     0.0126

------------------------------------------------------------------------------
       hrate |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
hrate        |
        gini |   5.476528   27.13021     0.20   0.840     -47.6977    58.65075
       _cons |   7.729059   11.38011     0.68   0.497    -14.57554    30.03366
-------------+----------------------------------------------------------------
W_s001       |
       hrate |  -.4645531   .3635528    -1.28   0.201    -1.177104    .2479973
------------------------------------------------------------------------------
Wald test of spatial terms:          chi2(1) = 1.63       Prob > chi2 = 0.2013