Impacts in spatial lag models
impacts.Rd
The calculation of impacts for spatial lag and spatial Durbin models is needed in order to interpret the regression coefficients correctly, because of the spillovers between the terms in these data generation processes (unlike the spatial error model). Methods for “SLX” and Bayesian fitted models are also provided, the former do not need MC simulations, while the latter pass through MCMC draws.
Usage
#\method{impacts}{sarlm}(obj, \dots, tr, R = NULL, listw = NULL, evalues=NULL,
# useHESS = NULL, tol = 1e-06, empirical = FALSE, Q=NULL)
#\method{impacts}{lagmess}(obj, ..., R=NULL, listw=NULL, tol=1e-6,
# empirical=FALSE)
#\method{impacts}{SLX}(obj, ...)
#\method{impacts}{MCMC_sar_g}(obj, ..., tr=NULL, listw=NULL, evalues=NULL, Q=NULL)
#\method{impacts}{MCMC_sem_g}(obj, ..., tr=NULL, listw=NULL, evalues=NULL, Q=NULL)
#\method{impacts}{MCMC_sac_g}(obj, ..., tr=NULL, listw=NULL, evalues=NULL, Q=NULL)
# S3 method for class 'LagImpact'
plot(x, ..., choice="direct", trace=FALSE, density=TRUE)
# S3 method for class 'LagImpact'
print(x, ..., reportQ=NULL)
# S3 method for class 'LagImpact'
summary(object, ..., zstats=FALSE, short=FALSE, reportQ=NULL)
#\method{print}{WXImpact}(x, ...)
#\method{summary}{WXImpact}(object, ..., adjust_k=(attr(object, "type") == "SDEM"))
# S3 method for class 'LagImpact'
HPDinterval(obj, prob = 0.95, ..., choice="direct")
intImpacts(rho, beta, P, n, mu, Sigma, irho, drop2beta, bnames, interval,
type, tr, R, listw, evalues, tol, empirical, Q, icept, iicept, p, mess=FALSE,
samples=NULL, zero_fill = NULL, dvars = NULL)
Arguments
- obj
A spatial regression object created by
lagsarlm
or bylmSLX
; inHPDinterval.LagImpact
, a LagImpact object- ...
Arguments passed through to methods in the coda package
- tr
A vector of traces of powers of the spatial weights matrix created using
trW
, for approximate impact measures; if not given,listw
must be given for exact measures (for small to moderate spatial weights matrices); the traces must be for the same spatial weights as were used in fitting the spatial regression, and must be row-standardised- listw
If
tr
is not given, a spatial weights object as created bynb2listw
; they must be the same spatial weights as were used in fitting the spatial regression, but do not have to be row-standardised- evalues
vector of eigenvalues of spatial weights matrix for impacts calculations
- n
defaults to
length(obj$residuals)
; in the method forgmsar
objects it may be used in panel settings to compute the impacts for cross-sectional weights only, suggested by Angela Parenti- R
If given, simulations are used to compute distributions for the impact measures, returned as
mcmc
objects; the objects are used for convenience but are not output by an MCMC process- useHESS
Use the Hessian approximation (if available) even if the asymptotic coefficient covariance matrix is available; used for comparing methods
- tol
Argument passed to
mvrnorm
: tolerance (relative to largest variance) for numerical lack of positive-definiteness in the coefficient covariance matrix- empirical
Argument passed to
mvrnorm
(default FALSE): if true, the coefficients and their covariance matrix specify the empirical not population mean and covariance matrix- Q
default NULL, else an integer number of cumulative power series impacts to calculate if
tr
is given- reportQ
default NULL; if TRUE and
Q
given as an argument toimpacts
, report impact components- x, object
LagImpact objects created by
impacts
methods- zstats
default FALSE, if TRUE, also return z-values and p-values for the impacts based on the simulations
- short
default FALSE, if TRUE passed to the print summary method to omit printing of the mcmc summaries
- choice
One of three impacts: direct, indirect, or total
- trace
Argument passed to
plot.mcmc
: plot trace plots- density
Argument passed to
plot.mcmc
: plot density plots- prob
Argument passed to
HPDinterval.mcmc
: a numeric scalar in the interval (0,1) giving the target probability content of the intervals- adjust_k
default TRUE if SDEM else FALSE, adjust internal OLS SDEM standard errors by dividing by n rather than (n-k) (default changed and bug fixed after 0.7-8; standard errors now ML in SDEM summary and impacts summary and identical - for SLX use FALSE)
- rho, beta, P, mu, Sigma, irho, drop2beta, bnames, interval, type, icept, iicept, p, mess, samples, zero_fill, dvars
internal arguments shared inside impacts methods
Details
If called without R
being set, the method returns the direct, indirect and total impacts for the variables in the model, for the variables themselves in tha spatial lag model case, for the variables and their spatial lags in the spatial Durbin (mixed) model case. The spatial lag impact measures are computed using eq. 2.46 (LeSage and Pace, 2009, p. 38), either using the exact dense matrix (when listw
is given), or traces of powers of the weights matrix (when tr
is given). When the traces are created by powering sparse matrices, the exact and the trace methods should give very similar results, unless the number of powers used is very small, or the spatial coefficient is close to its bounds.
If R
is given, simulations will be used to create distributions for the impact measures, provided that the fitted model object contains a coefficient covariance matrix. The simulations are made using mvrnorm
with the coefficients and their covariance matrix from the fitted model.
The simulations are stored as mcmc
objects as defined in the coda package; the objects are used for convenience but are not output by an MCMC process. The simulated values of the coefficients are checked to see that the spatial coefficient remains within its valid interval — draws outside the interval are discarded.
If a model is fitted with the “Durbin=” set to a formula subsetting the explanatory variables, the impacts object returned reports Durbin impacts for variables included in the formula and lag impacts for the other variables.
When Q
and tr
are given, addition impact component results are provided for each step in the traces of powers of the weights matrix up to and including the Q
'th power. This increases computing time because the output object is substantially increased in size in proportion to the size of Q
.
The method for gmsar
objects is only for those of type
SARAR
output by gstsls
, and assume that the spatial error coefficient is fixed, and thus omitted from the coefficients and covariance matrix used for simulation.
Value
An object of class LagImpact.
If no simulation is carried out, the object returned is a list with:
- direct
numeric vector
- indirect
numeric vector
- total
numeric vector
and a matching Qres
list attribute if Q
was given.
If simulation is carried out, the object returned is a list with:
- res
a list with three components as for the non-simulation case, with a matching
Qres
list attribute ifQ
was given- sres
a list with three
mcmc
matrices, for the direct, indirect and total impacts with a matchingQmcmc
list attribute ifQ
was given
References
LeSage J and RK Pace (2009) Introduction to Spatial Econometrics. CRC Press, Boca Raton, pp. 33–42, 114–115; LeSage J and MM Fischer (2008) Spatial growth regressions: model specification, estimation and interpretation. Spatial Economic Analysis 3 (3), pp. 275–304.
Roger Bivand, Gianfranco Piras (2015). Comparing Implementations of Estimation Methods for Spatial Econometrics. Journal of Statistical Software, 63(18), 1-36. doi:10.18637/jss.v063.i18 .
Author
Roger Bivand Roger.Bivand@nhh.no
Examples
require("sf", quietly=TRUE)
columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
#require("spdep", quietly=TRUE)
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])
listw <- spdep::nb2listw(col.gal.nb)
ev <- eigenw(listw)
lobj <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw,
control=list(pre_eig=ev))
summary(lobj)
#>
#> Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = columbus, listw = listw,
#> control = list(pre_eig = ev))
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -37.4497093 -5.4565567 0.0016387 6.7159553 24.7107978
#>
#> Type: lag
#> Coefficients: (asymptotic standard errors)
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 46.851431 7.314754 6.4051 1.503e-10
#> INC -1.073533 0.310872 -3.4533 0.0005538
#> HOVAL -0.269997 0.090128 -2.9957 0.0027381
#>
#> Rho: 0.40389, LR test value: 8.4179, p-value: 0.0037154
#> Asymptotic standard error: 0.12071
#> z-value: 3.3459, p-value: 0.00082027
#> Wald statistic: 11.195, p-value: 0.00082027
#>
#> Log likelihood: -183.1683 for lag model
#> ML residual variance (sigma squared): 99.164, (sigma: 9.9581)
#> Number of observations: 49
#> Number of parameters estimated: 5
#> AIC: 376.34, (AIC for lm: 382.75)
#> LM test for residual autocorrelation
#> test value: 0.19184, p-value: 0.66139
#>
mobj <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, Durbin=TRUE,
control=list(pre_eig=ev))
summary(mobj)
#>
#> Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = columbus, listw = listw,
#> Durbin = TRUE, control = list(pre_eig = ev))
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -37.15904 -6.62594 -0.39823 6.57561 23.62757
#>
#> Type: mixed
#> Coefficients: (asymptotic standard errors)
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 45.592896 13.128680 3.4728 0.0005151
#> INC -0.939088 0.338229 -2.7765 0.0054950
#> HOVAL -0.299605 0.090843 -3.2980 0.0009736
#> lag.INC -0.618375 0.577052 -1.0716 0.2838954
#> lag.HOVAL 0.266615 0.183971 1.4492 0.1472760
#>
#> Rho: 0.38251, LR test value: 4.1648, p-value: 0.041272
#> Asymptotic standard error: 0.16237
#> z-value: 2.3557, p-value: 0.018488
#> Wald statistic: 5.5493, p-value: 0.018488
#>
#> Log likelihood: -182.0161 for mixed model
#> ML residual variance (sigma squared): 95.051, (sigma: 9.7494)
#> Number of observations: 49
#> Number of parameters estimated: 7
#> AIC: 378.03, (AIC for lm: 380.2)
#> LM test for residual autocorrelation
#> test value: 0.101, p-value: 0.75063
#>
mobj1 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, Durbin= ~ INC,
control=list(pre_eig=ev))
summary(mobj1)
#>
#> Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = columbus, listw = listw,
#> Durbin = ~INC, control = list(pre_eig = ev))
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -37.62163 -6.13108 0.11211 6.70682 24.76777
#>
#> Type: mixed
#> Coefficients: (asymptotic standard errors)
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 51.951213 12.577339 4.1305 3.619e-05
#> INC -1.038812 0.337656 -3.0765 0.002094
#> HOVAL -0.269345 0.090406 -2.9793 0.002889
#> lag.INC -0.254653 0.544298 -0.4679 0.639887
#>
#> Rho: 0.35028, LR test value: 3.4351, p-value: 0.063823
#> Asymptotic standard error: 0.1617
#> z-value: 2.1662, p-value: 0.030293
#> Wald statistic: 4.6926, p-value: 0.030293
#>
#> Log likelihood: -183.065 for mixed model
#> ML residual variance (sigma squared): 99.846, (sigma: 9.9923)
#> Number of observations: 49
#> Number of parameters estimated: 6
#> AIC: 378.13, (AIC for lm: 379.57)
#> LM test for residual autocorrelation
#> test value: 2.5646, p-value: 0.10928
#>
W <- as(listw, "CsparseMatrix")
trMatc <- trW(W, type="mult")
trMC <- trW(W, type="MC")
set.seed(1)
impacts(lobj, listw=listw)
#> Impact measures (lag, exact):
#> Direct Indirect Total
#> INC -1.1225156 -0.6783818 -1.8008973
#> HOVAL -0.2823163 -0.1706152 -0.4529315
impacts(lobj, tr=trMatc)
#> Impact measures (lag, trace):
#> Direct Indirect Total
#> INC -1.1225156 -0.6783818 -1.8008973
#> HOVAL -0.2823163 -0.1706152 -0.4529315
impacts(lobj, tr=trMC)
#> Impact measures (lag, trace):
#> Direct Indirect Total
#> INC -1.1247738 -0.6761235 -1.8008973
#> HOVAL -0.2828842 -0.1700472 -0.4529315
impacts(lobj, evalues=ev)
#> Impact measures (lag, evalues):
#> Direct Indirect Total
#> INC -1.1225156 -0.6783818 -1.8008973
#> HOVAL -0.2823163 -0.1706152 -0.4529315
library(coda)
lobjIQ5 <- impacts(lobj, tr=trMatc, R=200, Q=5)
summary(lobjIQ5, zstats=TRUE, short=TRUE)
#> Impact measures (lag, trace):
#> Direct Indirect Total
#> INC -1.1225156 -0.6783818 -1.8008973
#> HOVAL -0.2823163 -0.1706152 -0.4529315
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.3298544 0.3834114 0.5945946
#> HOVAL 0.1014420 0.1261509 0.2033617
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -3.417467 -1.886887 -3.112575
#> HOVAL -2.895853 -1.551116 -2.406724
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.00063207 0.059176 0.0018546
#> HOVAL 0.00378129 0.120874 0.0160963
summary(lobjIQ5, zstats=TRUE, short=TRUE, reportQ=TRUE)
#> Impact measures (lag, trace):
#> Direct Indirect Total
#> INC -1.1225156 -0.6783818 -1.8008973
#> HOVAL -0.2823163 -0.1706152 -0.4529315
#> =================================
#> Impact components
#> $direct
#> INC HOVAL
#> Q1 -1.073533466 -0.2699971236
#> Q2 0.000000000 0.0000000000
#> Q3 -0.038985415 -0.0098049573
#> Q4 -0.005269654 -0.0013253350
#> Q5 -0.003276079 -0.0008239444
#>
#> $indirect
#> INC HOVAL
#> Q1 0.00000000 0.000000000
#> Q2 -0.43358910 -0.109049054
#> Q3 -0.13613675 -0.034238831
#> Q4 -0.06546038 -0.016463497
#> Q5 -0.02529105 -0.006360781
#>
#> $total
#> INC HOVAL
#> Q1 -1.07353347 -0.269997124
#> Q2 -0.43358910 -0.109049054
#> Q3 -0.17512216 -0.044043788
#> Q4 -0.07073004 -0.017788832
#> Q5 -0.02856713 -0.007184726
#>
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.3298544 0.3834114 0.5945946
#> HOVAL 0.1014420 0.1261509 0.2033617
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -3.417467 -1.886887 -3.112575
#> HOVAL -2.895853 -1.551116 -2.406724
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.00063207 0.059176 0.0018546
#> HOVAL 0.00378129 0.120874 0.0160963
#> ========================================================
#> Simulated impact components z-values:
#> $Direct
#> INC HOVAL
#> Q1 -3.3247602 -2.9008692
#> Q2 NaN NaN
#> Q3 -1.7540115 -1.4638039
#> Q4 -1.2444388 -1.0830402
#> Q5 -0.9405222 -0.8474166
#>
#> $Indirect
#> INC HOVAL
#> Q1 NaN NaN
#> Q2 -2.6977076 -2.1475985
#> Q3 -1.7540115 -1.4638039
#> Q4 -1.2444388 -1.0830402
#> Q5 -0.9405222 -0.8474166
#>
#> $Total
#> INC HOVAL
#> Q1 -3.3247602 -2.9008692
#> Q2 -2.6977076 -2.1475985
#> Q3 -1.7540115 -1.4638039
#> Q4 -1.2444388 -1.0830402
#> Q5 -0.9405222 -0.8474166
#>
#>
#> Simulated impact components p-values:
#> $Direct
#> INC HOVAL
#> Q1 0.00088495 0.0037213
#> Q2 NA NA
#> Q3 0.07942853 0.1432475
#> Q4 0.21333812 0.2787906
#> Q5 0.34694975 0.3967630
#>
#> $Indirect
#> INC HOVAL
#> Q1 NA NA
#> Q2 0.0069819 0.031746
#> Q3 0.0794285 0.143248
#> Q4 0.2133381 0.278791
#> Q5 0.3469497 0.396763
#>
#> $Total
#> INC HOVAL
#> Q1 0.00088495 0.0037213
#> Q2 0.00698187 0.0317457
#> Q3 0.07942853 0.1432475
#> Q4 0.21333812 0.2787906
#> Q5 0.34694975 0.3967630
#>
impacts(mobj, listw=listw)
#> Impact measures (mixed, exact):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
impacts(mobj, tr=trMatc)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
impacts(mobj, tr=trMC)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0462717 -1.4759609 -2.52223255
#> HOVAL -0.2829384 0.2295114 -0.05342697
impacts(mobj1, tr=trMatc)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0968247 -0.8939687 -1.9907934
#> HOVAL -0.2781941 -0.1363596 -0.4145537
impacts(mobj1, listw=listw)
#> Impact measures (mixed, exact):
#> Direct Indirect Total
#> INC -1.0968247 -0.8939687 -1.9907934
#> HOVAL -0.2781941 -0.1363596 -0.4145537
# \dontrun{
try(impacts(mobj, evalues=ev), silent=TRUE)
#> Impact measures (mixed, evalues):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
# }
summary(impacts(mobj, tr=trMatc, R=200), short=TRUE, zstats=TRUE)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.3407851 0.8610832 0.9221567
#> HOVAL 0.0980867 0.3285062 0.3625254
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -3.017200 -1.7533600 -2.7522499
#> HOVAL -2.931757 0.6507956 -0.2035056
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.0025512 0.07954 0.0059187
#> HOVAL 0.0033705 0.51518 0.8387399
summary(impacts(mobj1, tr=trMatc, R=200), short=TRUE, zstats=TRUE)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0968247 -0.8939687 -1.9907934
#> HOVAL -0.2781941 -0.1363596 -0.4145537
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.3752297 0.6525338 0.7183806
#> HOVAL 0.1078220 0.1277117 0.1990840
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -2.902700 -1.247249 -2.649084
#> HOVAL -2.637881 -1.168002 -2.177921
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.0036996 0.21231 0.008071
#> HOVAL 0.0083426 0.24281 0.029412
xobj <- lmSLX(CRIME ~ INC + HOVAL, columbus, listw)
summary(impacts(xobj))
#> Impact measures (SlX, glht, n-k):
#> Direct Indirect Total
#> INC -1.1081273 -1.3834468 -2.49157410
#> HOVAL -0.2949095 0.2261538 -0.06875574
#> ========================================================
#> Standard errors:
#> Direct Indirect Total
#> INC 0.3749956 0.5591789 0.4928197
#> HOVAL 0.1013524 0.2026169 0.2049626
#> ========================================================
#> Z-values:
#> Direct Indirect Total
#> INC -2.955041 -2.474068 -5.0557523
#> HOVAL -2.909744 1.116164 -0.3354551
#>
#> p-values:
#> Direct Indirect Total
#> INC 0.0031263 0.013358 4.287e-07
#> HOVAL 0.0036172 0.264352 0.73728
#>
eobj <- errorsarlm(CRIME ~ INC + HOVAL, columbus, listw, etype="emixed")
summary(impacts(eobj), adjust_k=TRUE)
#> Impact measures (SDEM, glht, n):
#> Direct Indirect Total
#> INC -1.0695301 -1.1967736 -2.2663036
#> HOVAL -0.2803441 0.1467585 -0.1335856
#> ========================================================
#> Standard errors:
#> Direct Indirect Total
#> INC 0.32471853 0.5689676 0.6209448
#> HOVAL 0.09180929 0.2008722 0.2323518
#> ========================================================
#> Z-values:
#> Direct Indirect Total
#> INC -3.293714 -2.1034124 -3.6497665
#> HOVAL -3.053548 0.7306064 -0.5749284
#>
#> p-values:
#> Direct Indirect Total
#> INC 0.00098873 0.03543 0.00026248
#> HOVAL 0.00226152 0.46502 0.56533971
#>
# \dontrun{
mobj1 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed",
method="Matrix", control=list(fdHess=TRUE))
summary(mobj1)
#>
#> Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = columbus, listw = listw,
#> type = "mixed", method = "Matrix", control = list(fdHess = TRUE))
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -37.15904 -6.62594 -0.39823 6.57561 23.62757
#>
#> Type: mixed
#> Coefficients: (asymptotic standard errors)
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 45.592896 14.240041 3.2017 0.0013660
#> INC -0.939088 0.343069 -2.7373 0.0061942
#> HOVAL -0.299605 0.090393 -3.3145 0.0009182
#> lag.INC -0.618375 0.607708 -1.0176 0.3088903
#> lag.HOVAL 0.266615 0.181524 1.4688 0.1418998
#>
#> Rho: 0.38251, LR test value: 4.1648, p-value: 0.041272
#> Asymptotic standard error: 0.17375
#> z-value: 2.2015, p-value: 0.027702
#> Wald statistic: 4.8465, p-value: 0.027702
#>
#> Log likelihood: -182.0161 for mixed model
#> ML residual variance (sigma squared): 95.051, (sigma: 9.7494)
#> Number of observations: 49
#> Number of parameters estimated: 7
#> AIC: 378.03, (AIC for lm: 380.2)
#> LM test for residual autocorrelation
#> test value: 0.101, p-value: 0.75063
#>
set.seed(1)
summary(impacts(mobj1, tr=trMatc, R=1000), zstats=TRUE, short=TRUE)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.34686331 0.8324743 0.8959688
#> HOVAL 0.09085583 0.3131242 0.3483785
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -3.023902 -1.8284275 -2.8695190
#> HOVAL -3.120537 0.7910739 -0.1028036
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.0024954 0.067485 0.004111
#> HOVAL 0.0018052 0.428901 0.918119
summary(impacts(mobj, tr=trMatc, R=1000), zstats=TRUE, short=TRUE)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.3123750 0.8291512 0.8821167
#> HOVAL 0.0922758 0.2961092 0.3267773
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -3.330304 -1.8060414 -2.8769263
#> HOVAL -3.099811 0.8140556 -0.1376722
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.00086751 0.070912 0.0040157
#> HOVAL 0.00193644 0.415613 0.8904995
mobj2 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed",
method="Matrix", control=list(fdHess=TRUE, optimHess=TRUE))
summary(impacts(mobj2, tr=trMatc, R=1000), zstats=TRUE, short=TRUE)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.32853332 0.8044059 0.8615603
#> HOVAL 0.09291975 0.3169361 0.3571304
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -3.231204 -1.8690203 -2.9771674
#> HOVAL -3.026494 0.7323897 -0.1374858
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.0012327 0.06162 0.0029093
#> HOVAL 0.0024741 0.46393 0.8906468
mobj3 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed",
method="spam", control=list(fdHess=TRUE))
summary(impacts(mobj3, tr=trMatc, R=1000), zstats=TRUE, short=TRUE)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> INC -1.0418080 -1.4804246 -2.52223255
#> HOVAL -0.2836325 0.2302055 -0.05342697
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> INC 0.32866009 0.8664620 0.9215792
#> HOVAL 0.09837849 0.3110899 0.3492674
#>
#> Simulated z-values:
#> Direct Indirect Total
#> INC -3.190433 -1.7325351 -2.766712
#> HOVAL -2.890221 0.7694814 -0.128720
#>
#> Simulated p-values:
#> Direct Indirect Total
#> INC 0.0014206 0.083178 0.0056625
#> HOVAL 0.0038497 0.441608 0.8975792
# }
# \dontrun{
data(boston, package="spData")
Wb <- as(spdep::nb2listw(boston.soi), "CsparseMatrix")
trMatb <- trW(Wb, type="mult")
gp2mMi <- lagsarlm(log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) +
I(RM^2) + AGE + log(DIS) + log(RAD) + TAX + PTRATIO + B + log(LSTAT),
data=boston.c, spdep::nb2listw(boston.soi), type="mixed", method="Matrix",
control=list(fdHess=TRUE), trs=trMatb)
summary(gp2mMi)
#>
#> Call:lagsarlm(formula = log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) +
#> I(RM^2) + AGE + log(DIS) + log(RAD) + TAX + PTRATIO + B +
#> log(LSTAT), data = boston.c, listw = spdep::nb2listw(boston.soi),
#> type = "mixed", method = "Matrix", trs = trMatb, control = list(fdHess = TRUE))
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.6316833 -0.0629790 -0.0090776 0.0682421 0.6991072
#>
#> Type: mixed
#> Coefficients: (asymptotic standard errors)
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.89816225 0.24400203 7.7793 7.327e-15
#> CRIM -0.00571021 0.00093857 -6.0839 1.173e-09
#> ZN 0.00069091 0.00051874 1.3319 0.1828931
#> INDUS -0.00111343 0.00307380 -0.3622 0.7171778
#> CHAS1 -0.04163225 0.02738839 -1.5201 0.1284937
#> I(NOX^2) -0.01034950 0.19358633 -0.0535 0.9573639
#> I(RM^2) 0.00794979 0.00102109 7.7856 6.883e-15
#> AGE -0.00128789 0.00048929 -2.6322 0.0084838
#> log(DIS) -0.12404108 0.09510145 -1.3043 0.1921304
#> log(RAD) 0.05863502 0.02257529 2.5973 0.0093957
#> TAX -0.00049084 0.00012146 -4.0412 5.317e-05
#> PTRATIO -0.01319853 0.00595331 -2.2170 0.0266227
#> B 0.00056383 0.00011084 5.0867 3.643e-07
#> log(LSTAT) -0.24724454 0.02265149 -10.9152 < 2.2e-16
#> lag.CRIM -0.00464215 0.00173900 -2.6694 0.0075978
#> lag.ZN -0.00037937 0.00070703 -0.5366 0.5915659
#> lag.INDUS 0.00025064 0.00385911 0.0649 0.9482165
#> lag.CHAS1 0.12518252 0.04083949 3.0652 0.0021750
#> lag.I(NOX^2) -0.38640403 0.22253428 -1.7364 0.0824967
#> lag.I(RM^2) -0.00451252 0.00148919 -3.0302 0.0024440
#> lag.AGE 0.00149678 0.00068470 2.1860 0.0288128
#> lag.log(DIS) -0.00453785 0.10056961 -0.0451 0.9640104
#> lag.log(RAD) -0.00940702 0.03127787 -0.3008 0.7636002
#> lag.TAX 0.00041083 0.00017859 2.3004 0.0214237
#> lag.PTRATIO 0.00060355 0.00789994 0.0764 0.9391011
#> lag.B -0.00050781 0.00014107 -3.5996 0.0003187
#> lag.log(LSTAT) 0.09846781 0.03574183 2.7550 0.0058697
#>
#> Rho: 0.59578, LR test value: 181.68, p-value: < 2.22e-16
#> Asymptotic standard error: 0.037474
#> z-value: 15.899, p-value: < 2.22e-16
#> Wald statistic: 252.76, p-value: < 2.22e-16
#>
#> Log likelihood: 300.6131 for mixed model
#> ML residual variance (sigma squared): 0.016011, (sigma: 0.12654)
#> Number of observations: 506
#> Number of parameters estimated: 29
#> AIC: -543.23, (AIC for lm: -363.55)
#> LM test for residual autocorrelation
#> test value: 29.772, p-value: 4.8604e-08
#>
summary(impacts(gp2mMi, tr=trMatb, R=1000), zstats=TRUE, short=TRUE)
#> Impact measures (mixed, trace):
#> Direct Indirect Total
#> CRIM -0.0074555753 -0.0181548470 -0.0256104223
#> ZN 0.0006979073 0.0000727985 0.0007707058
#> INDUS -0.0012029822 -0.0009314672 -0.0021344494
#> CHAS1 -0.0198526431 0.2265453879 0.2066927447
#> I(NOX^2) -0.0955268252 -0.8859909283 -0.9815177535
#> I(RM^2) 0.0079983430 0.0005050175 0.0085033605
#> AGE -0.0011296134 0.0016463650 0.0005167515
#> log(DIS) -0.1410601685 -0.1770277708 -0.3180879393
#> log(RAD) 0.0641735546 0.0576102594 0.1217838140
#> TAX -0.0004651543 0.0002672119 -0.0001979424
#> PTRATIO -0.0147737151 -0.0163846522 -0.0311583673
#> B 0.0005265343 -0.0003879424 0.0001385920
#> log(LSTAT) -0.2578403220 -0.1102143882 -0.3680547101
#> ========================================================
#> Simulation results ( variance matrix):
#> ========================================================
#> Simulated standard errors
#> Direct Indirect Total
#> CRIM 0.0010076566 0.0036285971 0.0040401747
#> ZN 0.0004896474 0.0012385892 0.0012617113
#> INDUS 0.0028820705 0.0060789543 0.0057788737
#> CHAS1 0.0271174416 0.0816948950 0.0902306553
#> I(NOX^2) 0.1798525319 0.2954129272 0.2426994629
#> I(RM^2) 0.0010995238 0.0031443424 0.0036252679
#> AGE 0.0004766510 0.0012848631 0.0013546129
#> log(DIS) 0.0884514383 0.1106832550 0.0757291955
#> log(RAD) 0.0197637995 0.0513249209 0.0502885515
#> TAX 0.0001172963 0.0003281755 0.0003385766
#> PTRATIO 0.0054150426 0.0127887825 0.0122251822
#> B 0.0001051363 0.0002388721 0.0002375770
#> log(LSTAT) 0.0224736420 0.0610706224 0.0660453166
#>
#> Simulated z-values:
#> Direct Indirect Total
#> CRIM -7.4242633 -5.04782172 -6.3852730
#> ZN 1.4302178 0.09961643 0.6528326
#> INDUS -0.4184439 -0.10883366 -0.3231737
#> CHAS1 -0.7260661 2.79074703 2.3085362
#> I(NOX^2) -0.5230875 -3.05728030 -4.1089450
#> I(RM^2) 7.3426845 0.17905211 2.3822949
#> AGE -2.4149822 1.25401260 0.3396769
#> log(DIS) -1.5778895 -1.66514935 -4.2766960
#> log(RAD) 3.2376719 1.17611638 2.4727850
#> TAX -3.9726814 0.78133925 -0.6189573
#> PTRATIO -2.7323855 -1.29137856 -2.5612005
#> B 5.0000793 -1.62377140 0.5800914
#> log(LSTAT) -11.4429357 -1.77731839 -5.5372039
#>
#> Simulated p-values:
#> Direct Indirect Total
#> CRIM 1.1346e-13 4.4688e-07 1.7109e-10
#> ZN 0.1526545 0.9206489 0.513864
#> INDUS 0.6756226 0.9133344 0.746564
#> CHAS1 0.4677982 0.0052587 0.020969
#> I(NOX^2) 0.6009133 0.0022336 3.9747e-05
#> I(RM^2) 2.0939e-13 0.8578968 0.017205
#> AGE 0.0157360 0.2098374 0.734100
#> log(DIS) 0.1145910 0.0958830 1.8969e-05
#> log(RAD) 0.0012051 0.2395484 0.013406
#> TAX 7.1068e-05 0.4346030 0.535944
#> PTRATIO 0.0062878 0.1965724 0.010431
#> B 5.7307e-07 0.1044246 0.561853
#> log(LSTAT) < 2.22e-16 0.0755159 3.0734e-08
#data(house, package="spData")
#lw <- spdep::nb2listw(LO_nb)
#form <- formula(log(price) ~ age + I(age^2) + I(age^3) + log(lotsize) +
# rooms + log(TLA) + beds + syear)
#lobj <- lagsarlm(form, house, lw, method="Matrix",
# control=list(fdHess=TRUE), trs=trMat)
#summary(lobj)
#loobj <- impacts(lobj, tr=trMat, R=1000)
#summary(loobj, zstats=TRUE, short=TRUE)
#lobj1 <- stsls(form, house, lw)
#loobj1 <- impacts(lobj1, tr=trMat, R=1000)
#summary(loobj1, zstats=TRUE, short=TRUE)
#mobj <- lagsarlm(form, house, lw, type="mixed",
# method="Matrix", control=list(fdHess=TRUE), trs=trMat)
#summary(mobj)
#moobj <- impacts(mobj, tr=trMat, R=1000)
#summary(moobj, zstats=TRUE, short=TRUE)
# }