Review of RE covariance matrices (\(\Sigma\))
- \(\Sigma\) is doubly block-diagonal
- one block for every random-effect term (maybe only 1)
- one sub-block for every cluster within a term, maybe only 1
(R-side effects)
Correlation structures in lme
- separate for R-side (
corStruct
: corAR1
,
corCompSymm
, etc.), G-side pdStruct
library(nlme)
data(Nile)
nile <- data.frame(date = 1871:1970, flow = c(Nile))
fit1 <- gls(flow ~ date, correlation = corAR1(), data = nile)
R-side modeling
- structure of residual variance
- Ironically, most R packages don’t do R-side structures
specially
- Can construct an observation-level factor with the appropriate
structure
- May need to set the actual residual variance term to zero
(
glmmTMB
, blme
)
Correlation structures in lme4
- not much! strong assumption of unstructured covariance matrix
||
operator separates components into separate
terms
- e.g.
(1 + x + y || f)
\(\to\)
(1|f) + (0 + x | f) + (0 + y | f)
- purely semantic; factor variables aren’t handled well
afex::mixed()
adds a layer to produce a diagonal
covariance matrix even for factors (by splitting/creating dummies)
Correlation structures in glmmTMB
: native
library(glmmTMB)
nile$dummy <- factor(1)
fit2 <- glmmTMB(flow ~ date + ar1(factor(date) + 0 | dummy),
data = nile,
dispformula = ~ 0,
REML = TRUE)
## Warning in finalizeTMB(TMBStruc, obj, fit, h, data.tmb.old): Model convergence
## problem; non-positive-definite Hessian matrix. See vignette('troubleshooting')
## Warning in finalizeTMB(TMBStruc, obj, fit, h, data.tmb.old): Model convergence
## problem; false convergence (8). See vignette('troubleshooting'),
## help('diagnose')
Correlation structure via smooths
mgcv
smooths can (as of recently) be used in
glmmTMB
- may be rough around the edges
- fewer downstream methods (inference, effective df) available
- also
gamm4
(but less convenient and flexible)
- constructs \(\boldsymbol Z\), \(\Sigma\) appropriately
- \(\Sigma\) is always known up to a
constant
- e.g. scale, shape parameters for autoregressive/spatial terms must
be specified a priori
- less important if controlling for correlation rather than making
inferences
mgcv
smooths
- long list: basic are different forms of 1D splines
- Gaussian process smooths
- Markov random field smooths (low rank
approximation)
Reduced-rank (factor-analytic) smooths
- factor-analytic models;
rr(...)
in glmmTMB
, gllvm
package (more specialized)
sdmTMB
- relatively new package
- uses meshes, stochastic PDE framework from INLA for sparsity
pedigrees etc.
- I know a lot less about these!
- make \(\Sigma\) proportional to the
pedigree/phylogenetic matrix
- how to hack with
glmmTMB
(map
function)
refs