
Last chance! 50% off unlimited learning
Sale ends in
The function fits a matrix exponential spatial lag model, using optim
to find the value of alpha
, the spatial coefficient.
lagmess(formula, data = list(), listw, zero.policy = NULL, na.action = na.fail,
q = 10, start = -2.5, control=list(), method="BFGS", verbose=NULL,
use_expm=FALSE)
# S3 method for lagmess
summary(object, ...)
# S3 method for lagmess
print(x, ...)
# S3 method for summary.lagmess
print(x, digits = max(5, .Options$digits - 3),
signif.stars = FALSE, ...)
# S3 method for lagmess
residuals(object, ...)
# S3 method for lagmess
deviance(object, ...)
# S3 method for lagmess
coef(object, ...)
# S3 method for lagmess
fitted(object, ...)
# S3 method for lagmess
logLik(object, ...)
a symbolic description of the model to be fit. The details
of model specification are given for lm()
an optional data frame containing the variables in the model. By default the variables are taken from the environment which the function is called.
a listw
object created for example by nb2listw
default NULL, use global option value; if TRUE assign zero to the lagged value of zones without
neighbours, if FALSE assign NA - causing lagmess()
to terminate with an error
a function (default options("na.action")
), can also be na.omit
or na.exclude
with consequences for residuals and fitted values - in these cases the weights list will be subsetted to remove NAs in the data. It may be necessary to set zero.policy to TRUE because this subsetting may create no-neighbour observations. Note that only weights lists created without using the glist argument to nb2listw
may be subsetted.
default 10; number of powers of the spatial weights to use
starting value for numerical optimization, should be a small negative number
control parameters passed to optim
default BFGS
, method passed to optim
default NULL, use global option value; if TRUE report function values during optimization
default FALSE; if TRUE use expm::expAtv
instead of a truncated power series of W
Objects of classes lagmess
or summary.lagmess
to be passed to methods
the number of significant digits to use when printing
logical. If TRUE, "significance stars" are printed for each coefficient.
further arguments passed to or from other methods
The function returns an object of class lagmess
with components:
the lm
object returned after fitting alpha
the spatial coefficient
the standard error of the spatial coefficient using the numerical Hessian
the value of rho
implied by alpha
the object returned by optim
the number of powers of the spatial weights used
the starting value for numerical optimization used
(possibly) named vector of excluded or omitted observations if non-default na.action argument used
the log likelihood of the aspatial model for the same data
The underlying spatial lag model:
where
we see that in the ML case q
.
J. P. LeSage and R. K. Pace (2007) A matrix exponential specification. Journal of Econometrics, 140, 190-214; J. P. LeSage and R. K. Pace (2009) Introduction to Spatial Econometrics. CRC Press, Chapter 9.
# NOT RUN {
data(baltimore, package="spData")
baltimore$AGE <- ifelse(baltimore$AGE < 1, 1, baltimore$AGE)
lw <- nb2listw(knn2nb(knearneigh(cbind(baltimore$X, baltimore$Y), k=7)))
obj1 <- lm(log(PRICE) ~ PATIO + log(AGE) + log(SQFT),
data=baltimore)
lm.morantest(obj1, lw)
lm.LMtests(obj1, lw, test="all")
system.time(obj2 <- lagmess(log(PRICE) ~ PATIO + log(AGE) + log(SQFT), data=baltimore, listw=lw))
summary(obj2)
system.time(obj2a <- lagmess(log(PRICE) ~ PATIO + log(AGE) + log(SQFT), data=baltimore, listw=lw,
use_expm=TRUE))
summary(obj2a)
obj3 <- lagsarlm(log(PRICE) ~ PATIO + log(AGE) + log(SQFT), data=baltimore, listw=lw)
summary(obj3)
# }
# NOT RUN {
data(boston, package="spData")
lw <- nb2listw(boston.soi)
gp2 <- 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, lw, method="Matrix")
summary(gp2)
gp2a <- lagmess(CMEDV ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) + I(RM^2)
+ AGE + log(DIS) + log(RAD) + TAX + PTRATIO + B + log(LSTAT),
data=boston.c, lw)
summary(gp2a)
# }
Run the code above in your browser using DataLab