impacts.sarlm: Impacts in spatial lag models

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/impacts.R

Description

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## S3 method for class 'sarlm'
impacts(obj, ..., tr, R = NULL, listw = NULL, useHESS = NULL,
 tol = 1e-06, empirical = FALSE, Q=NULL)
## S3 method for class 'stsls'
impacts(obj, ..., tr, R = NULL, listw = NULL,
 tol = 1e-06, empirical = FALSE, Q=NULL)
## S3 method for class 'gmsar'
impacts(obj, ..., n = NULL, tr = NULL, R = NULL, listw = NULL,
 tol = 1e-06, empirical = FALSE, Q=NULL)
## S3 method for class 'lagmess'
impacts(obj, ..., R=NULL, listw=NULL, tol=1e-6, empirical=FALSE)
## S3 method for class 'SLX'
impacts(obj, ...)
## S3 method for class 'MCMC_sar_g'
impacts(obj, ..., tr=NULL, listw=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)
## S3 method for class 'WXImpact'
print(x, ...)
## S3 method for class 'WXImpact'
summary(object, ..., adjust_k=FALSE)
## 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, tol, empirical, Q, icept, iicept, p, mess=FALSE,
 samples=NULL)

Arguments

obj

A spatial regression object created by lagsarlm, lagmess or by lmSLX; in HPDinterval.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 by nb2listw; they must be the same spatial weights as were used in fitting the spatial regression, but do not have to be row-standardised

n

defaults to length(obj$residuals); in the method for gmsar 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 to impacts, 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

adjust ML SDEM standard errors by dividing by (n-k) rather than n

rho, beta, P, mu, Sigma, irho, drop2beta, bnames, interval, type, icept, iicept, p, mess, samples

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.

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 if Q was given

sres

a list with three mcmc matrices, for the direct, indirect and total impacts with a matching Qmcmc list attribute if Q was given

Author(s)

Roger Bivand Roger.Bivand@nhh.no

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. http://www.jstatsoft.org/v63/i18/.

See Also

trW, lagsarlm, nb2listw, mvrnorm, plot.mcmc, summary.mcmc, HPDinterval

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
example(columbus)
listw <- nb2listw(col.gal.nb)
lobj <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw)
summary(lobj)
mobj <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed")
summary(mobj)
W <- as(listw, "CsparseMatrix")
trMatc <- trW(W, type="mult")
trMC <- trW(W, type="MC")
set.seed(1)
impacts(lobj, listw=listw)
impacts(lobj, tr=trMatc)
impacts(lobj, tr=trMC)
lobj1 <- stsls(CRIME ~ INC + HOVAL, columbus, listw)
loobj1 <- impacts(lobj1, tr=trMatc, R=200)
summary(loobj1, zstats=TRUE, short=TRUE)
library(coda)
HPDinterval(loobj1)
lobj1r <- stsls(CRIME ~ INC + HOVAL, columbus, listw, robust=TRUE)
loobj1r <- impacts(lobj1r, tr=trMatc, R=200)
summary(loobj1r, zstats=TRUE, short=TRUE)
lobjIQ5 <- impacts(lobj, tr=trMatc, R=200, Q=5)
summary(lobjIQ5, zstats=TRUE, short=TRUE)
summary(lobjIQ5, zstats=TRUE, short=TRUE, reportQ=TRUE)
impacts(mobj, listw=listw)
impacts(mobj, tr=trMatc)
impacts(mobj, tr=trMC)
summary(impacts(mobj, tr=trMatc, R=200), zstats=TRUE)
xobj <- lmSLX(CRIME ~ INC + HOVAL, columbus, listw)
summary(impacts(xobj))
eobj <- errorsarlm(CRIME ~ INC + HOVAL, columbus, listw, etype="emixed")
summary(impacts(eobj), adjust_k=TRUE)
## Not run: 
mobj1 <- lagsarlm(CRIME ~ INC + HOVAL, columbus, listw, type="mixed", 
method="Matrix", control=list(fdHess=TRUE))
summary(mobj1)
set.seed(1)
summary(impacts(mobj1, tr=trMatc, R=1000), zstats=TRUE, short=TRUE)
summary(impacts(mobj, tr=trMatc, R=1000), zstats=TRUE, short=TRUE)
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)
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)
data(boston)
Wb <- as(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, nb2listw(boston.soi), type="mixed", method="Matrix", 
control=list(fdHess=TRUE), trs=trMatb)
summary(gp2mMi)
summary(impacts(gp2mMi, tr=trMatb, R=1000), zstats=TRUE, short=TRUE)
data(house)
lw <- 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)

## End(Not run)

spdep documentation built on Aug. 19, 2017, 3:01 a.m.