The structure of random-effect models adjustable by spaMM can generally be described by the following steps.
First, independent and identically distributed (iid) random effects u are drawn from one of the following distributions: Gaussian with zero mean, unit variance, and identity link; Beta-distributed, where \(u\) ~
\(B(1/(2\lambda),1/(2\lambda))\) with mean=1/2, and var\(=\lambda/[4(1+\lambda)]\); and with logit link v=logit(u)
;
Gamma-distributed random effects, where \(u\) ~ Gamma(shape=
1+1/\(\lambda\),scale=1/\(\lambda\)): see Gamma
for allowed links and further details; and Inverse-Gamma-distributed random effects, where \(u\) ~
inverse-Gamma(shape=
1+1/\(\lambda\),rate=1/\(\lambda\)): see inverse.Gamma
for allowed links and further details.
Second, a transformation v\(=f\)(u) is applied (this defines v whose elements are still iid). By default, v=u for gaussian random effects but not necessarily for other distributions of random effects (see Gamma
).
Third, correlated random effects are obtained as Mv, where the matrix M can describe spatial correlation between observed locations, block effects (or repeated observations in given locations), and possibly also correlations involving unobserved locations (as is often the case for autoregressive models). In most cases M is determined from the model formula, but it can also be controlled by covStruct argument. M takes the form ZL or ZAL, where Z is determined from the model formula, the optional A factor is given by the optional "AMatrices"
attribute of argument covStruct
of HLCor
(also handled by fitme
and corrHLfit
), and L can be determined from the model formula or from covStruct
. In particular:
*
Z is typically an incidence matrix: its elements \(z_{ij}\) are 1 if the \(i\)th observation is affected by the \(j\)th element of ALb
, and zero otherwise.
*
For spatial random effects, L is typically the Cholesky “square root” of a correlation matrix determined by the random effect specification (e.g., Matern(...)
), or given by the covStruct
argument. This may be meaningful only for Gaussian random effects. Coefficients for each level of a random-coefficient model can also be represented as Lv where L is the “square root” of a correlation matrix.
*
If there is one response value par location, L for a spatial random effect is thus a square matrix whose dimension is the number of observations. Alternatively, several observations may be taken in the same location, and a matrix Z (automatically constructed) tells which element of Lv affects each observation. The linear predictor then contains a term of the form ZLv, where dim(Z)
is (number of observations,number of locations).
*
in IMRF
random effects (IMRF for Interpolated Markov Random Fields), the realized random effects in response locations are defined as linear combinations ALv of random effects Lv in distinct locations. In that case the dimension of L is the number of such distinct locations, an automatically constructed A matrix maps them to the observed locations, and Z again maps them to possibly repeated observations in observed locations.