# Cumulative counts or counts for Poisson regression

I have a set of data with measurements X1 and X2 across multiple time points, T1, T2 and T3. I would like to conduct a Poisson regression using X1 and X2 on the counts of a phenomenon. An example of how my dataset would like is as follows (pardon my inelegant code):

library(lme4)
set.seed(888)
df <- data.frame(SubID = sort(rep(1:10, 3)), Time = rep(1:3, 10), Count = sample(0:9, 30, replace = TRUE))
df <- data.frame(df, Cumulative.count = unlist(lapply(1:10, function(n) cumsum(df[cbind(c((1:10*3)-2), c(1:10*3))[n,1]:cbind(c((1:10*3)-2), c(1:10*3))[n,2],"Count"]))), x1 = rnorm(30), x2 = rnorm(30), x3 = rnorm(30))


As can be seen, I have 2 "counts" variable. One is cumulative, one is not. My question is should I be doing:

model.count <- glmer(Count ~ x1 + x2 + x3 + (Time|SubID), family = poisson(link = "log"), data = df)


OR:

model.cumulative.count <- glmer(Cumulative.count ~ x1 + x2 + x3 + (Time|SubID), family = poisson(link = "log"), data = df)

• If you have the cumulative counts your points won't be independent. If you do that in a single glm it will violate the assumption of independence. Feb 21, 2013 at 0:16
• I was of the understanding that in glmm, the points within a grouping variable (in this case would be subjects) would be expected to have a dependent relationship? I might have a misunderstanding of glmm.
– RJ-
Feb 21, 2013 at 0:20
• Wow. I missed the extra m there, reading it as glm somehow. Yes, if the form of the resulting dependence is correctly modelled, it shouldn't matter. Feb 21, 2013 at 0:23
• ok would you want to put that as an answer?
– RJ-
Feb 21, 2013 at 1:13
• No, I don't think so. I don't feel myself expert enough on glmm's to justify the circumstances relating to the 'if' part of my comment without a fair bit more work on my part. Better to leave it for someone better able to justify it. Feb 21, 2013 at 1:39

The approach generally taken is to regress the counts on features that were present during the intervals during which the counts accumulated. The length of the interval is used as an offset after applying log() to the values to match the default link for a Poisson model. The data situation described does not justify anything very fancy. A glm model would suffice. The first offset would be log(T1) ,,, assuming T0 was 0 ... and the second offset would be log(T2-T1).

Edit: with the better description/illustration of your data, I would say definitely to go with the first of your alternatives. You are not interested in the cumulative value per period but the incremental value per period. See comment below.

• Thanks for the answer! Point of clarification, do you mean that I just compute the difference in scores for both Y and X?
– RJ-
Feb 21, 2013 at 8:11
• That doesn't sound right. I was thinking that you would be computing successive differences in T values to get durations. The logging them as offset values. Then regressing using a log-link and Poisson errors those counts (Y's) on any predictors (X's) that were measured during those intervals.
– DWin
Feb 21, 2013 at 8:15
• thanks for the clarification. I am not sure if I understood you correctly. Given that my T values are consistent across all subjects (i.e. they are all measured at the same fixed time), do I still need to use the offsets? To make things clearer, I have added a reproducible example. Thanks much for your advice.
– RJ-
Feb 21, 2013 at 17:49
• The Y would be Count (which is same as diff(c(0, Cumulative.count)) ). The x's are your predictors and this would be in a repeated measures model that appropriately groups data by SubID and Time. Since your "Time" variable is not really time but instead appears to be a "period marker" I would not log() it. You should be able to consider construct contrasts that there is a) no variation over time, b) that there is a rising trend over time, or c) that there is a rise or dip in the middle (quadratic contrast).
– DWin
Feb 21, 2013 at 18:28