# 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. –  Glen_b Feb 21 '13 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. –  b70568b5 Feb 21 '13 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. –  Glen_b Feb 21 '13 at 0:23
ok would you want to put that as an answer? –  b70568b5 Feb 21 '13 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. –  Glen_b Feb 21 '13 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).
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 '13 at 18:28