Learn R Programming

HSAR (version 0.6.0)

sar: SAR model estimation

Description

The sar() function implements a standard spatial econometrics model (SAR) or a spatially lagged dependent variable model using the Markov chain Monte Carlo (McMC) simulation approach.

Usage

sar(
  formula,
  data = NULL,
  W,
  burnin = 5000,
  Nsim = 10000,
  thinning = 1,
  parameters.start = NULL
)

Value

A list.

cbetas

A matrix with the MCMC samples of the draws for the coefficients.

Mbetas

A vector of estimated mean values of regression coefficients.

SDbetas

The standard deviations of estimated regression coefficients.

Mrho

The estimated mean of the lower-level spatial autoregressive parameter \(\rho\).

SDrho

The standard deviation of the estimated lower-level spatial autoregressive parameter.

Msigma2e

The estimated mean of the lower-level variance parameter \(\sigma^{2}_{e} \).

SDsigma2e

The standard deviation of the estimated lower-level variance parameter \(\sigma^{2}_{e} \).

DIC

The deviance information criterion (DIC) of the fitted model.

pd

The effective number of parameters of the fitted model.

Log_Likelihood

The log-likelihood of the fitted model.

R_Squared

A pseudo R square model fit indicator.

impact_direct

Summaries of the direct impact of a covariate effect on the outcome variable.

impact_idirect

Summaries of the indirect impact of a covariate effect on the outcome variable.

impact_total

Summaries of the total impact of a covariate effect on the outcome variable.

Arguments

formula

A symbolic description of the model to fit. A formula for the covariate part of the model using the syntax of the stats::lm() function fitting standard linear regression models. Neither the response variable nor the explanatory variables are allowed to contain NA values.

data

A data.frame containing variables used in the formula object.

W

The N by N spatial weights matrix or neighbourhood matrix where N is the number of spatial units. The formulation of W could be based on geographical distances separating units or based on geographical contiguity. To ensure the maximum value of the spatial autoregressive parameter \(\rho\) less than 1, W is usually row-normalised before implementing the SAR model. As in most cases, spatial weights matrix is very sparse, therefore W here should be converted to a sparse matrix before imported into the sar() function to save computational burden and reduce computing time. More specifically, W should be a column-oriented numeric sparse matrices of a dgCMatrix class defined in the Matrix package. The converion between a dense numeric matrix and a sparse numeric matrix is made quite convenient through the Matrix library.

burnin

The number of McMC samples to discard as the burnin period.

Nsim

The total number of McMC samples to generate.

thinning

MCMC thinning factor.

parameters.start

A list with names "rho", "sigma2e", and "beta" corresponding to initial values for the model parameters \(\rho, \sigma^2_e\) and the regression coefficients respectively.

References

Anselin, L. (1988). Spatial Econometrics: Methods and Models. Dordrecht: Kluwer Academic Publishers.

LeSage, J. P., and R. K. Pace. (2009). Introduction to Spatial Econometrics. Boca Raton, FL: CRC Press/Taylor & Francis

Examples

Run this code
data(landprice)
head(landprice)
data(land)

# extract the land parcel level spatial weights matrix
library(spdep)
library(Matrix)
nb.25 <- spdep::dnearneigh(land,0,2500)
# to a weights matrix
dist.25 <- spdep::nbdists(nb.25,land)
dist.25 <- lapply(dist.25,function(x) exp(-0.5 * (x / 2500)^2))
mat.25 <- spdep::nb2mat(nb.25,glist=dist.25,style="W")
W <- as(mat.25,"dgCMatrix")

## run the sar() function
res.formula <- lnprice ~ lnarea + lndcbd + dsubway + dpark + dele +
                popden + crimerate + as.factor(year)
betas= coef(lm(formula=res.formula,data=landprice))
pars=list(rho = 0.5, sigma2e = 2.0, betas = betas)
# \donttest{
res <- sar(res.formula,data=landprice,W=W,
           burnin=500, Nsim=1000, thinning=1,
           parameters.start=pars)
summary(res)
# }

Run the code above in your browser using DataLab