florianhartig / DHARMa

Diagnostics for HierArchical Regession Models
http://florianhartig.github.io/DHARMa/
200 stars 21 forks source link

Residual grouping according to RE groups that are used in the model #383

Open florianhartig opened 11 months ago

florianhartig commented 11 months ago

Due to a question via email, I wondered if it is a problem to group residuals according to groups that also used as REs in the model.

Based on a quick simulation, I didn't see any problems with that.

library(DHARMa)
library(lme4)
testData = createData(sampleSize = 5000,numGroups = 1000, randomEffectVariance = 2)
fittedModel <- glmer(observedResponse ~ Environment1 + (1|group), family = "poisson", data = testData)

simulationOutput <- simulateResiduals(fittedModel = fittedModel, plot = F)

simulationOutput = recalculateResiduals(simulationOutput , group = testData$group)
plot(simulationOutput)

I would like to check further because I had suspected that there could be issues similar to #43