Learn R Programming

spdep (version 0.3-8)

lagsarlm: Spatial simultaneous autoregressive lag model estimation

Description

Maximum likelihood estimation of spatial simultaneous autoregressive lag and mixed models of the form:

$$y = \rho W y + X \beta + \varepsilon$$

where $$ is found by optim() using method "L-BFGS-B" first and $$ and other parameters by generalized least squares subsequently. In the mixed model, the spatially lagged independent variables are added to X. lagsarlm(formula, data=list(), listw, na.action=na.fail, type="lag", method="eigen", quiet=TRUE, zero.policy=FALSE, interval = c(-1, 0.999), tol.solve=1.0e-10, tol.opt=.Machine$double.eps^0.5, control, optim=FALSE, sparsedebug=FALSE)formula{a symbolic description of the model to be fit. The details of model specification are given for lm()} 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 listw object created for example by nb2listw} na.action{a function (default na.fail), 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.} type{default "lag", may be set to "mixed"; when "mixed", the lagged intercept is dropped for spatial weights style "W", that is row-standardised weights, but otherwise included} method{"eigen" (default) - the Jacobian is computed as the product of (1 - rho*eigenvalue) using eigenw, "SparseM" for strictly symmetric weights lists of styles "B", "C" and "U", or made symmetric by similarity (Ord, 1975, Appendix C) if possible for styles "W" and "S", using code from the SparseM package to calculate the determinant, and "sparse" - (deprecated from this release) computes the determinant of the sparse matrix (I - rho*W) directly using logSpwdet. } quiet{default=TRUE; if FALSE, reports function values during optimization.} zero.policy{if TRUE assign zero to the lagged value of zones without neighbours, if FALSE (default) assign NA - causing lagsarlm() to terminate with an error} interval{search interval for autoregressive parameter when not using method="eigen"; default is c(-1,1)} tol.solve{the tolerance for detecting linear dependencies in the columns of matrices to be inverted - passed to solve() (default=1.0e-10). This may be used if necessary to extract coefficient standard errors (for instance lowering to 1e-12), but errors in solve() may constitute indications of poorly scaled variables: if the variables have scales differing much from the autoregressive coefficient, the values in this matrix may be very different in scale, and inverting such a matrix is analytically possible by definition, but numerically unstable; rescaling the RHS variables alleviates this better than setting tol.solve to a very small value} tol.opt{the desired accuracy of the optimization - passed to optimize() (default=square root of double precision machine tolerance)} control{A list of control parameters passed to optim, se details in optim} optim{If TRUE use experimental optim branch and control argument} sparsedebug{if TRUE, writes a log file on sparse matrix operations (name sparsestats) in the current directory. To be used if sparse estimation fails!}

When using the sparse method, the user takes (unfortunately) full responsibility for possible failures, including R terminating with a core dump! Safeguards have been put in place to try to trap errant behaviour in the sparse functions' memory allocation, but they may not always help. When sparsedebug is TRUE, a log file (sparsestats) is written in the working directory - the figure of interest is the number of allocated blocks. At present, spwdet will fail when this increases over the number initially allocated, but will not release memory allocated by the sparse functions. In the event of problems, save your workspace and quit R. Problems seem to be related to larger n, and to an unknown trigger precipitating incontrolled fillin, in the course of which the sparse routines lose track of their memory pointers, and then provoke a segmentation fault trying to free unallocated memory.
A list object of class sarlm type{"lag" or "mixed"} rho{simultaneous autoregressive lag coefficient} coefficients{GLS coefficient estimates} rest.se{asymptotic standard errors if ase=TRUE} LL{log likelihood value at computed optimum} s2{GLS residual variance} SSE{sum of squared GLS errors} parameters{number of parameters estimated} lm.model{the lm object returned when estimating for $=0$ method{the method used to calculate the Jacobian} call{the call used to create this object} residuals{GLS residuals} lm.target{the lm object returned for the GLS fit} fitted.values{Difference between residuals and response variable} se.fit{Not used yet} formula{model formula} ase{TRUE if method=eigen} LLs{if ase=FALSE (for method="SparseM" and method="sparse"), the log likelihood values of models estimated dropping each of the independent variables in turn, used in the summary function as a substitute for variable coefficient significance tests} rho.se{if ase=TRUE, the asymptotic standard error of $$ LMtest{if ase=TRUE, the Lagrange Multiplier test for the absence of spatial autocorrelation in the lag model residuals} zero.policy{zero.policy for this model} na.action{(possibly) named vector of excluded or omitted observations if non-default na.action argument used}

The internal sar.lag.mixed.* functions return the value of the log likelihood function at $$. Cliff, A. D., Ord, J. K. 1981 Spatial processes, Pion; Ord, J. K. 1975 Estimation methods for models of spatial interaction, Journal of the American Statistical Association, 70, 120-126; Anselin, L. 1988 Spatial econometrics: methods and models. (Dordrecht: Kluwer); Anselin, L. 1995 SpaceStat, a software program for the analysis of spatial data, version 1.80. Regional Research Institute, West Virginia University, Morgantown, WV (www.spacestat.com); Anselin L, Bera AK (1998) Spatial dependence in linear regression models with an introduction to spatial econometrics. In: Ullah A, Giles DEA (eds) Handbook of applied economic statistics. Marcel Dekker, New York, pp. 237-289. [object Object],[object Object]

lm, errorsarlm, eigenw, logSpwdet, predict.sarlm, residuals.sarlm

data(oldcol) COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, nb2listw(COL.nb), method="eigen", quiet=FALSE) COL.lag.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, nb2listw(COL.nb, style="W"), method="eigen", control=list(trace=3, fnscale=-1, factr=.Machine$double.eps^0.5, pgtol=.Machine$double.eps^0.5)) COL.lag.SM <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, nb2listw(COL.nb), method="SparseM", quiet=FALSE) summary(COL.lag.eig, correlation=TRUE) summary(COL.lag.SM, correlation=TRUE) COL.lag.B <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, nb2listw(COL.nb, style="B")) summary(COL.lag.B, correlation=TRUE) COL.mixed.B <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, nb2listw(COL.nb, style="B"), type="mixed", tol.solve=1e-9) summary(COL.mixed.B, correlation=TRUE) COL.mixed.W <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, nb2listw(COL.nb, style="W"), type="mixed") summary(COL.mixed.W, correlation=TRUE) NA.COL.OLD <- COL.OLD NA.COL.OLD$CRIME[20:25] <- NA COL.lag.NA <- lagsarlm(CRIME ~ INC + HOVAL, data=NA.COL.OLD, nb2listw(COL.nb), na.action=na.exclude, tol.opt=.Machine$double.eps^0.4) COL.lag.NA$na.action COL.lag.NA resid(COL.lag.NA) spatial

Arguments