# sar: SAR model estimation In HSAR: Hierarchical Spatial Autoregressive Model

## 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

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

## Arguments

 `formula` A symbolic description of the model to fit. A formula for the covariate part of the model using the syntax of the 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 ρ 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 burdon 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 ρ, σ^2_e and the regression coefficients respectively.

## Value

A list object containing:

 `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 ρ. `SDrho` The standard deviation of the estimated lower-level spatial autoregressive parameter. `Msigma2e` The estimated mean of the lower-level variance parameter σ^{2}_{e} . `SDsigma2e` The standard deviation of the estimated lower-level variance parameter σ^{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.

## Author(s)

Guanpeng Dong, Richard Harris, Angelos Mimis mimis@panteion.gr

## 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

`hsar`, `landprice`, `Beijingdistricts`, `landSPDF`
 ``` 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``` ```data(landprice) head(landprice) data(landSPDF) # extract the land parcel level spatial weights matrix library(spdep) nb.25 <- spdep::dnearneigh(landSPDF,0,2500) # to a weights matrix dist.25 <- spdep::nbdists(nb.25,landSPDF) 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 ) ## Not run: res <- sar(res.formula,data=landprice,W=W, burnin=500, Nsim=1000, thinning=1, parameters.start=pars) summary(res) ## End(Not run) ```