Learn R Programming

brms (version 2.19.0)

sar: Spatial simultaneous autoregressive (SAR) structures

Description

Set up an spatial simultaneous autoregressive (SAR) term in brms. The function does not evaluate its arguments -- it exists purely to help set up a model with SAR terms.

Usage

sar(M, type = "lag")

Value

An object of class 'sar_term', which is a list of arguments to be interpreted by the formula parsing functions of brms.

Arguments

M

An object specifying the spatial weighting matrix. Can be either the spatial weight matrix itself or an object of class listw or nb, from which the spatial weighting matrix can be computed.

type

Type of the SAR structure. Either "lag" (for SAR of the response values) or "error" (for SAR of the residuals). More information is provided in the 'Details' section.

Details

The lagsar structure implements SAR of the response values: $$y = \rho W y + \eta + e$$ The errorsar structure implements SAR of the residuals: $$y = \eta + u, u = \rho W u + e$$ In the above equations, \(\eta\) is the predictor term and \(e\) are independent normally or t-distributed residuals. Currently, only families gaussian and student support SAR structures.

See Also

autocor-terms

Examples

Run this code
if (FALSE) {
data(oldcol, package = "spdep")
fit1 <- brm(CRIME ~ INC + HOVAL + sar(COL.nb, type = "lag"),
            data = COL.OLD, data2 = list(COL.nb = COL.nb),
            chains = 2, cores = 2)
summary(fit1)
plot(fit1)

fit2 <- brm(CRIME ~ INC + HOVAL + sar(COL.nb, type = "error"),
            data = COL.OLD, data2 = list(COL.nb = COL.nb),
            chains = 2, cores = 2)
summary(fit2)
plot(fit2)
}

Run the code above in your browser using DataLab