# GLM for count data

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"))
summary(aov(mod))


Is it the correct way?

Thanks!

• 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. Apr 8 '14 at 13:02
• It's a categorical variable...in the real case they are two strings Apr 8 '14 at 13:05
• Over-dispersion is something to watch out for - is the spread of proportions for different participants unexpectedly large within each condition? Apr 8 '14 at 13:14
• 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. Apr 8 '14 at 13:46
• In my first comment read "generalized" for "general"; in my third the deviance in question is the residual deviance. Apr 8 '14 at 14:24