Lesson 6 - More Random Effects
14 December 2023
Overdispersion via random effects
What about REML?
Residuals
So is the Laplace approximation working?
ML variance estimates are known to be biased
REML variance estimates are unbiased in linear normal models and generally less biased than ML estimates
REML estimates can be obtained by declaring all the fixed effects other than the variances as random (don’t add anything to the function you minimize)
Pretty much ignored and not studied/evaluated in stock assessment
In standard regression (with normal errors) the maximum likelihood estimate for residual error variance is (residual SS)/n.
The minimum variance unbiased estimate for linear regression is (residual SS)/(n-2).
This is approximately unbiased for nonlinear regression.
The RTMB reml procedure will produce the approximatley unbiased estimates (see musky_vonb_reml.R)
This is just to demo of what REML is doing for a known answer case!
standard Pearson residuals
Problems with standard Pearson residuals
One step ahead (osa) aka recursive quantile residuals
defined as (obs-pred)/sd
sd is what the standard deviation for (obs-pred) should be given your model and model estimates
Idea is that if raw residuals are approximately normal and independent then Pearson residuals will be approximately normal, independent, with equal (1) variance.
Actual residuals typically:
Not normal
Not independent
In addition, we really want to look at residuals in some sense integrated over random effects, rather than at the best estimates of random effects
The capability is built into RTMB and in theory can be applied almost automatically: oneStepPredict(obj) - with data set up using OBS
Numerically intensive and can be numerically tricky.
The theory underlying this is pretty intense. See:
Thygesen et al. Environ Ecol Stat 24(2): 317–339.
Approximation depends on approximate normality of the combined vector or parameter estimates and random estimates.
This is why we generally don’t specify non-normal distributions for random effects.
RTMB includes a helper function that checks the Laplace approximation
Call as checkConsistency(obj) or as checkConsistency(obj,estimate=TRUE). Run summary on result.
Requires you have set up your function for simulation (using OBS) (and the simulations work!).
Usually want estimate=TRUE optional argument. This conducts a full simulation and evaluates parameter bias and whether simulated data are constent with assumed distributions.of simulation.