easystats / performance

:muscle: Models' quality and performance metrics (R2, ICC, LOO, AIC, BF, ...)
https://easystats.github.io/performance/
GNU General Public License v3.0
1.01k stars 87 forks source link

Outliers in glmmTMB #95

Open strengejacke opened 4 years ago

strengejacke commented 4 years ago

From R mixed models list:

I don't know about packages that will directly work with glmmTMB objects, but computing Cook's distances can be easily done by hand. Let b be the vector with the estimated fixed effects from the model and V(b) the corresponding var-cov matrix. You can extract these with fixef() and vcov() from your model. Now leave out either a single observation or a cluster of observations (e.g., all observations corresponding to an individual) and let b_{-i} denote the estimated fixed effects when fitting the data to this subset of the dataset. Then Cook's distances is simply

Di = (b - b{-i})' V(b)^{-1} (b - b_{-i})

Now rinse and repeat for every i, which is easily done in a loop. It might take a while to complete depending on how complex your model is.

Some might compute Di with V(b{-i})^{-1} in place of V(b)^{-1}. Can be done easily at the same time, so you could do both and compare.

strengejacke commented 1 year ago

@rempsyc Does check_outliers() work for glmmTMB?

rempsyc commented 1 year ago

No. We do have a method for it, but it is:

# Non-supported model classes ---------------------------------------

check_outliers.glmmTMB <- function(x, ...) {
  insight::format_alert(paste0("`check_outliers()` does not yet support models of class `", class(x)[1], "`."))
  NULL
}

😬