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):

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)


model.cumulative.count <- glmer(Cumulative.count ~ x1 + x2 + x3 + (Time|SubID), family = poisson(link = "log"), data = df)
  • $\begingroup$ 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. $\endgroup$ – Glen_b -Reinstate Monica Feb 21 '13 at 0:16
  • 1
    $\begingroup$ 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. $\endgroup$ – RJ- Feb 21 '13 at 0:20
  • $\begingroup$ 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. $\endgroup$ – Glen_b -Reinstate Monica Feb 21 '13 at 0:23
  • $\begingroup$ ok would you want to put that as an answer? $\endgroup$ – RJ- Feb 21 '13 at 1:13
  • $\begingroup$ 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. $\endgroup$ – Glen_b -Reinstate Monica 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).

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.

  • $\begingroup$ Thanks for the answer! Point of clarification, do you mean that I just compute the difference in scores for both Y and X? $\endgroup$ – RJ- Feb 21 '13 at 8:11
  • $\begingroup$ 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. $\endgroup$ – DWin Feb 21 '13 at 8:15
  • $\begingroup$ 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. $\endgroup$ – RJ- Feb 21 '13 at 17:49
  • $\begingroup$ 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). $\endgroup$ – DWin Feb 21 '13 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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