0

I conducted a generalized linear mixed effects model using R. Now. I want to check if the linearity assumption of my model is violated. First, I tried to create a plot of the residuals using plot(fitted(glmm), residuals(glmm) which gave me this graph: binary residuals

I am a complete newbie at this, so it is difficult for me to interpret this, but it does not look like other plots where the linearity assumption is fulfilled. So I researched a bit further and found one website that said that

this residual plot does not provide information about the model form assumptions for a dichotomous response logistic model. Models are assumed to be linear in each of the independent variables. This assumption can be checked with plots of the residuals versus each of the variables.

It followed with a code that you should use:

ggplot(data.frame(x1=pbDat$x1,pearson=residuals(gmm,type="pearson")),
      aes(x=x1,y=pearson)) +
    geom_point() +
    theme_bw()

ggplot(data.frame(x2=pbDat$x2,pearson=residuals(gmm,type="pearson")),
      aes(x=x2,y=pearson)) +
    geom_point() +
    theme_bw()

Naturally, I tried to use it for my model:

ggplot(data.frame(x1=dfb.2$pers_force,pearson=residuals(glmm,type="pearson")),
       aes(x=x1,y=pearson)) +
  geom_point() +
  theme_bw()

but it returned the following error: "arguments imply differing number of rows: 592, 585" What am I doing wrong, and how can I fix it? Does this method even make sense at all?

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • 1
    I feel like there might be two questions here, one about coding and one about checking the linearity assumptions of your model. For the statistics portion of the question you might find a more suitable answer on a sister website called cross validated. – Mike Jan 05 '21 at 16:13
  • For the coding bit: I suspect you have 7 (=592-585) `NA` values in your data. Try setting `na.action=na.exclude` when you fit your model ... – Ben Bolker Jan 05 '21 at 16:18

0 Answers0