Open coraliewilliams opened 1 year ago
glmmTMB
weight argument seems to be dealt with differently from the weight argument in glm
and lm
.
1. lm
Weights are used when data are only available in an averaged form (and actual data is unavailable). If non-NULL, weighted least squares is used with weights (that is, minimizing ‘sum(w*e^2)’)
2. glmmTMB
Weights are simple multipliers on the log-likelihood contributions of the observations. Weights are added to an observation by pretending multiple replicates are available. For binomial and poison families this coincides with the lm
definition. However, it does not coincide with the Gaussian family (see example code in issue below from Ben Bolker).
Additional comment: "It is probably not possible for us to adopt the glm definition consistently in glmmTMB as it generally requires a convolution property of the family to get the likelihood contribution of the average right. We do not have such properties for all our families."
This is discussed in the following issue on glmmTMB master branch: https://github.com/glmmTMB/glmmTMB/issues/285#issuecomment-355035400
--> Side comment when using REML=T for fixed variance components:
This comment (https://github.com/glmmTMB/glmmTMB/issues/833#issuecomment-1182959872) shows an example when a REML model in glmmTMB is not working compared to a ML model. The feedback from Ben Bolker is that it is an edge effect (they didn't foresee anyone fitting a REML model with all random effects parameters fixed in Gaussian family context).
This was resolve partly in merged into master branch on glmmTMB: https://github.com/glmmTMB/glmmTMB/commit/320a78d0b906e7c24f8c6a36f6e38b33df24245f
Another important note from: https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html
the glmmTMB package can set the residual variance to zero, by specifying dispformula = ~0
There is an rrBlupMethod6 package on CRAN (“Re-parametrization of mixed model formulation to allow for a fixed residual variance when using RR-BLUP for genom[e]wide estimation of marker effects”), but it seems fairly special-purpose.
How are weights specified as a default in glmmTMB function?
If weights are not specified within the function a vector of "1s" is set. Non-NULL weights can be used to indicate that different observations have different variances (with the values in weights being inversely proportional to the variances)