The standard response families gaussian
, binomial
, poisson
, and Gamma
are handled, as well as negative binomial (see negbin1
and negbin2
), zero-truncated poisson and negative binomial, beta (beta_resp
) and Conway-Maxwell-Poisson response (see Tpoisson
, Tnegbin
and COMPoisson
). A multi
family look-alike is also available for multinomial
response, with some constraints.
The variance parameter of residual error is denoted \(\phi\) (phi
): this is the residual variance for gaussian response, but for Gamma-distributed response, the residual variance is \(\phi\)\(\mu^2\) where \(\mu\) is expected response. A (possibly mixed-effects) linear predictor for \(\phi\), modeling heteroscedasticity, can be considered (see Examples).
The package fits models including several nested or crossed random effects, including autocorrelated ones. An interface is being developed allowing users to implement their own parametric correlation models (see corrFamily
), beyond the following ones which are built in spaMM:
* geostatistical (Matern
, Cauchy
),
* interpolated Markov Random Fields (IMRF
, MaternIMRFa
),
* autoregressive time-series (AR1
, ARp
, ARMA
),
* conditional autoregressive as specified by an adjacency
matrix,
* pairwise interactions with individual-level random effects, such as diallel experiments (diallel
),
* or any fixed correlation matrix (corrMatrix
).
GLMMs and HGLMs are fit via Laplace approximations for (1) the marginal likelihood with respect to random effects and (2) the restricted likelihood (as in REML), i.e. the likelihood of random effect parameters given the fixed effect estimates. All handled models can be formulated in terms of a linear predictor of the traditional form offset
+ X\(\beta\) + Z b, where X is the design matrix of fixed effects, \(\beta\) (beta
) is a vector of fixed-effect coefficients, Z is a “design matrix” for the random effects (which is instead denoted M=ZAL elsewhere in the package documentation), and b a vector of random effect values. The general structure of Mb is described in random-effects
.
Gaussian and non-gaussian random effects can be fitted. Different gaussian random-effect terms are handled, with the following effects:
* (1|<RHS>), for non-autocorrelated random effects as in lme4;
* (<LHS>|<RHS>), for random-coefficient terms as in lme4, *and
additional terms depending on the <LHS> type* (further detailed below);
* (<LHS> || <RHS>) is interpreted as in lme4: any such term is immediately
converted to ( (1|<RHS>) + (0+<LHS>|<RHS>) ). It should be counted as two
random effects for all purposes (e.g., for fixing the variances of the
random effects). However, this syntax is useless when the LHS includes a
factor (see help('lme4::expandDoubleVerts')).
* <prefix>(1|<RHS>), to specify autocorrelated random effects,
e.g. Matern(1|long+lat).
* <prefix>(<LHS>|<RHS>), where the <LHS> can be used to alter the
autocorrelated random effect as detailed below.
Different LHS types of gaussian (<LHS>|<RHS>)
random-effect terms are handled, with the following effects:
* <logical> (TRUE/FALSE): affects only responses for which <LHS> is TRUE;
* <factor built from a logical>: same a <logical> case;
* <factor not built from a logical>: random-coefficient term as in lme4;
* 0 + <factor not built from a logical>: same but contrasts are not used;
* factors specified by the mv(...) expression, generate random-coefficient
terms specific to multivariate-response models fitted by fitmv() (see
help("mv")). 0 + mv(...) has the expected effect of not using contrasts;
* <numeric> (but not '0+<numeric>'): random-coefficient term as in lme4,
with 2*2 covariance matrix of effects on Intercept and slope;
* 0 + <numeric>: no Intercept so no covariance matrix (random-slope-only
term);
* the "experimental" dummy() specifier described in the lme4 documentation
has been found to work with spaMM too.
The '0 + <numeric>' effect is achieved by direct control of the elements of the incidence matrix Z through the <LHS>
term: for numeric z
, such elements are multiplied by z
values, and thus provide a variance of order O(z
squared).
If one wishes to fit uncorrelated group-specific random-effects with distinct variances for different groups or for different response variables, three syntaxes are thus possible. The most general, suitable for fitting several variances (see help("GxE") for an example), is to fit a (0 + <factor>| <RHS>) random-coefficient term with correlation(s) fixed to 0. Alternatively, one can define numeric (0|1) variables for each group (as as.numeric(<boolean for given group membership>)
), and use each of them in a 0 + <numeric>
LHS (so that the variance of each such random effect is zero for response not belonging to the given group). Using dummy
factors for each level of the original factor can achieve the same effect without coding new variables in the data. These syntaxes are illustrated in the “Elementary multivariate-response” example below for two groups (males and females).
Gaussian <prefix>(<LHS>|<RHS>)
random-effect terms may be handled, with two main cases whether LHS types that imply estimating a random-coefficient covariance matrix (see composite-ranef
for details), or not. As an example of the latter, independent Matérn effects can be fitted for males and females by using the syntax Matern(male|.) + Matern(female|.)
, where male
and female
are TRUE/FALSE factors; and Matern(0+<numeric>|.)
represents an autocorrelated random-slope (only) term (or, equivalently, a direct specification of heteroscedasticity of the Matérn random effect). By contrast, Matern(<numeric>|.)
implies estimating a random-coefficient covariance matrix.
* Matern(<LHS>|<RHS>)
, corrMatrix(<LHS>|<RHS>)
, and (experimentally, with surely many limitations) <corrFamily>(<LHS>|<RHS>)
terms may be fitted for all the above LHS cases and RHS cases. The Matern
feature is experimental (introduced in version 3.12.0) and the <corrFamily>
one is even more so, with surely many limitations.
* For other <prefix>
, it is also possible to fit some random-effect terms involving a non-‘1
’ LHS, but then only the LHS types that do not imply estimating a random-coefficient covariance matrix are handled. In these autocorrelated random effects the <RHS>
is generally restricted to the simplest form, except for AR1 where the <.> %in% <.>
form of nested random effect is allowed.
The syntax (z-1|.)
, for numeric z
only, can also be used to fit some heteroscedastic non-Gaussian random effects. For example, a Gamma random-effect term (wei-1|block)
specifies an heteroscedastic Gamma random effect \(u\) with constant mean 1 and variance wei^2
\(\lambda\), where \(\lambda\) is still the estimated variance parameter. See Details of negbin
for a possible application. Here, this effect is not implemented through direct control of Z (multiplying the elements of an incidence matrix Z by wei
), as this would have a different effect on the distribution of the random effect term. (z|.)
is not defined for non-Gaussian random effects. It could mean that a correlation structure between random intercepts and random slopes for (say) Gamma-distributed random effects is considered, but such correlation structures are not well-specified by their correlation matrix.