florianhartig / DHARMa

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

Interpreting residual pattern for glmer #378

Closed kc-li closed 1 year ago

kc-li commented 1 year ago

Hi, I fitted a mixed logistic regression model where the dependent variable is a binary variable (switch:0/1), and the independent variables include both categorical (TONE, POS, GENDER, GENERATION, SPEAKER) and continuous variables (FREQUENCY):

The dataset has 98645 observations.

model <- glmer(switch ~ TONE + FREQUENCY + POS + GENDER + GENERATION + 
                                   (TONE|SPEAKER) +
                                   (1|TOKEN),
                           data = can,
                           family = binomial("logit"),
                           control=glmerControl(optimizer="bobyqa", 
                           optCtrl=list(maxfun=2e5),
                           calc.derivs=FALSE), 
                           na.action=na.omit
                          )

Using the DHARMa package, I got the following results, which I'm not sure how to interpret. Especially the residual vs. predicted figure, I've not seen such a pattern in the examples. Is it looking right?

simulationOutput.can <- simulateResiduals(fittedModel = model)
plot(simulationOutput.can)

image

Any suggestion would be appreciated. Thank you!

florianhartig commented 1 year ago

Hello,

there is nothing to see, your residuals look fine. However, the general plot usually looks good with 0/1 logistic regression.

See comments on the vignette, section on binomial data, https://cran.r-project.org/web/packages/DHARMa/vignettes/DHARMa.html#binomial-data on how to proceed.

Best, FH

kc-li commented 1 year ago

I see. Thank you for the suggestion!