The function fits a matrix exponential spatial lag model, using `optim`

to find the value of `alpha`

, the spatial coefficient.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
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 class 'lagmess'
summary(object, ...)
## S3 method for class 'lagmess'
print(x, ...)
## S3 method for class 'summary.lagmess'
print(x, digits = max(5, .Options$digits - 3),
signif.stars = FALSE, ...)
## S3 method for class 'lagmess'
residuals(object, ...)
## S3 method for class 'lagmess'
deviance(object, ...)
## S3 method for class 'lagmess'
coef(object, ...)
## S3 method for class 'lagmess'
fitted(object, ...)
## S3 method for class 'lagmess'
logLik(object, ...)
``` |

`formula` |
a symbolic description of the model to be fit. The details
of model specification are given for |

`data` |
an optional data frame containing the variables in the model. By default the variables are taken from the environment which the function is called. |

`listw` |
a |

`zero.policy` |
default NULL, use global option value; if TRUE assign zero to the lagged value of zones without
neighbours, if FALSE assign NA - causing |

`na.action` |
a function (default |

`q` |
default 10; number of powers of the spatial weights to use |

`start` |
starting value for numerical optimization, should be a small negative number |

`control` |
control parameters passed to |

`method` |
default |

`verbose` |
default NULL, use global option value; if TRUE report function values during optimization |

`use_expm` |
default FALSE; if TRUE use |

`x,object` |
Objects of classes |

`digits` |
the number of significant digits to use when printing |

`signif.stars` |
logical. If TRUE, "significance stars" are printed for each coefficient. |

`...` |
further arguments passed to or from other methods |

The underlying spatial lag model:

*y = rho W y + X beta + e*

where *rho* is the spatial parameter may be fitted by maximum likelihood. In that case, the log likelihood function includes the logartithm of cumbersome Jacobian term *|I - rho W|*. If we rewrite the model as:

*S y = X beta + e*

we see that in the ML case *S y = (I - rho W) y*. If W is row-stochastic, S may be expressed as a linear combination of row-stochastic matrices. By pre-computing the matrix *[y Wy, W^2y, ..., W^{q-1}y]*, the term *S y (alpha)* can readily be found by numerical optimization using the matrix exponential approach. *alpha* and *rho* are related as *rho = 1 - exp(alpha)*, conditional on the number of matrix power terms taken `q`

.

The function returns an object of class `lagmess`

with components:

`lmobj` |
the |

`alpha` |
the spatial coefficient |

`alphase` |
the standard error of the spatial coefficient using the numerical Hessian |

`rho` |
the value of |

`bestmess` |
the object returned by |

`q` |
the number of powers of the spatial weights used |

`start` |
the starting value for numerical optimization used |

`na.action` |
(possibly) named vector of excluded or omitted observations if non-default na.action argument used |

`nullLL` |
the log likelihood of the aspatial model for the same data |

Roger Bivand Roger.Bivand@nhh.no and Eric Blankmeyer

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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
data(baltimore)
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)
data(boston)
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)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.