I ran an experiment with an eye tracker and my data frame has this look:

               Condition   DWellsAOI1 DwellsAOI2  TotalDwells 
Participant1       1             12         13            25
Participant2       2            100         11           111
Participant3       1             50         50           100

and so on. DWellsAOI1 counts the number of dwells on AOI1. Each participant belongs to one condition only, and the duration of the experiment is not fixed, so different TotalDwells.

I was trying to check if there is a significant difference among the between conditions in terms of DwellsAOI1, and my first approach was to compute the percentages (DwellsAOI1/TotalDwells) and run anova. However, data violates both the assumptions.

I searched on Google and I found that I can use a generalized linear model (GLM) with binomial family.

Currently I'm running it like this:

mod <- glm(cbind(DwellsAOI1,TotalDwells-DwellsAOI1) ~ Condition,
               data=df, family=binomial("logit"))

Is it the correct way?


  • $\begingroup$ Might want to check whether you're treating Condition as a categorical or continuous variable - it'll make a difference if there are more than two levels. Some reading about general linear models would also be a good idea before you start using them in earnest. $\endgroup$ Commented Apr 8, 2014 at 13:02
  • $\begingroup$ It's a categorical variable...in the real case they are two strings $\endgroup$ Commented Apr 8, 2014 at 13:05
  • $\begingroup$ Over-dispersion is something to watch out for - is the spread of proportions for different participants unexpectedly large within each condition? $\endgroup$ Commented Apr 8, 2014 at 13:14
  • 1
    $\begingroup$ Given the differences in duration, & hence total dwells, is the spread of proportions for different participants unexpectedly large within each condition? Check the model diagnostics - unusually large deviance is a tell-tale sign. $\endgroup$ Commented Apr 8, 2014 at 13:46
  • 1
    $\begingroup$ In my first comment read "generalized" for "general"; in my third the deviance in question is the residual deviance. $\endgroup$ Commented Apr 8, 2014 at 14:24

1 Answer 1


You're making a strong assumption with this model: that the probability of dwelling on AOI1 in each trial depends only on the Condition factor & is not affected by variability between participants or between sessions. So the danger is a misleadingly precise estimate of the effect of Condition. Examine the model diagnostics carefully, & note that the residual deviance should be approximately equal to the residual degrees of freedom; much greater is a tell-tale sign of over-dispersion. If the assumption seems untenable, alternatives include fitting a beta-binomial model, using a quasi-likelihood approach with an estimated dispersion parameter, & fitting a generalized linear mixed model with a random intercept term representing the participant-session effect.

† To see this: the fitted model will be the same as if you'd summed up dwell counts across each condition before the analysis, leaving you with a two-way contingency table.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.