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)
mthere, reading it asglmsomehow. Yes, if the form of the resulting dependence is correctly modelled, it shouldn't matter. – Glen_b Feb 21 at 0:23