spautor {spmodel} | R Documentation |
Fit spatial autoregressive models
Description
Fit spatial linear models for areal data (i.e., spatial autoregressive models) using a variety of estimation methods, allowing for random effects, partition factors, and row standardization.
Usage
spautor(
formula,
data,
spcov_type,
spcov_initial,
estmethod = "reml",
random,
randcov_initial,
partition_factor,
W,
row_st = TRUE,
M,
range_positive = TRUE,
...
)
Arguments
formula |
A two-sided linear formula describing the fixed effect structure
of the model, with the response to the left of the |
data |
A data frame or |
spcov_type |
The spatial covariance type. Available options include
|
spcov_initial |
An object from |
estmethod |
The estimation method. Available options include
|
random |
A one-sided linear formula describing the random effect structure
of the model. Terms are specified to the right of the |
randcov_initial |
An optional object specifying initial and/or known values for the random effect variances. |
partition_factor |
A one-sided linear formula with a single term specifying the partition factor. The partition factor assumes observations from different levels of the partition factor are uncorrelated. |
W |
Weight matrix specifying the neighboring structure used.
Not required if |
row_st |
A logical indicating whether row standardization be performed on
|
M |
|
range_positive |
Whether the range should be constrained to be positive.
The default is |
... |
Other arguments to |
Details
The spatial linear model for areal data (i.e., spatial autoregressive model)
can be written as
y = X \beta + \tau + \epsilon
, where X
is the fixed effects design
matrix, \beta
are the fixed effects, \tau
is random error that is
spatially dependent, and \epsilon
is random error that is spatially
independent. Together, \tau
and \epsilon
are modeled using
a spatial covariance function, expressed as
de * R + ie * I
, where de
is the dependent error variance, R
is a matrix that controls the spatial dependence structure among observations,
ie
is the independent error variance, and I
is
an identity matrix. Note that de
and ie
must be non-negative while range
must be between the reciprocal of the maximum
eigenvalue of W
and the reciprocal of the minimum eigenvalue of
W
.
spcov_type
Details: Parametric forms for R
are given below:
car:
(I - range * W)^{-1}M
, weights matrixW
, symmetry condition matrixM
sar:
[(I - range * W)(I - range * W)^T]^{-1}
, weights matrixW
,^T
indicates matrix transpose
If there are observations with no neighbors, they are given a unique variance
parameter called extra
, which must be non-negative.
estmethod
Details: The various estimation methods are
-
reml
: Maximize the restricted log-likelihood. -
ml
: Maximize the log-likelihood.
By default, all spatial covariance parameters except ie
as well as all random effect variance parameters
are assumed unknown, requiring estimation. ie
is assumed zero and known by default
(in contrast to models fit using splm()
, where ie
is assumed
unknown by default). To change this default behavior, specify spcov_initial
(an NA
value for ie
in spcov_initial
to assume
ie
is unknown, requiring estimation).
random
Details: If random effects are used, the model
can be written as y = X \beta + Z1u1 + ... Zjuj + \tau + \epsilon
,
where each Z is a random effects design matrix and each u is a random effect.
partition_factor
Details: The partition factor can be represented in matrix form as P
, where
elements of P
equal one for observations in the same level of the partition
factor and zero otherwise. The covariance matrix involving only the
spatial and random effects components is then multiplied element-wise
(Hadmard product) by P
, yielding the final covariance matrix.
Observations with NA
response values are removed for model
fitting, but their values can be predicted afterwards by running
predict(object)
. This is the only way to perform prediction for
spautor()
models (i.e., the prediction locations must be known prior
to estimation).
Value
A list with many elements that store information about
the fitted model object. If spcov_type
or spcov_initial
are
length one, the list has class spautor
. Many generic functions that
summarize model fit are available for spautor
objects, including
AIC
, AICc
, anova
, augment
, BIC
, coef
,
cooks.distance
, covmatrix
, deviance
, fitted
, formula
,
glance
, glances
, hatvalues
, influence
,
labels
, logLik
, loocv
, model.frame
, model.matrix
,
plot
, predict
, print
, pseudoR2
, summary
,
terms
, tidy
, update
, varcomp
, and vcov
. If
spcov_type
or spcov_initial
are length greater than one, the
list has class spautor_list
and each element in the list has class
spautor
. glances
can be used to summarize spautor_list
objects, and the aforementioned spautor
generics can be used on each
individual list element (model fit).
Note
This function does not perform any internal scaling. If optimization is not stable due to large extremely large variances, scale relevant variables so they have variance 1 before optimization.
Examples
spmod <- spautor(log_trend ~ 1, data = seal, spcov_type = "car")
summary(spmod)