I have for the past two days read all the questions and answers I could find regarding my problem, but as I got only more insecure, I finally decided to post a question on my own. I'd very much appreciate your insight!
I have subjects for which an outcome (a count) is measured under two conditions
ID condition outcome
ID1 condition1 20
ID1 condition2 10
ID2 condition1 5
ID2 condition2 7
Since my outcome is a count, I fit a glmer with family=poisson, but I am uncertain as to what is the correct syntax to have the condition nested within ID.
m1: I think this is wrong as it only has a random intercept for the ID
m1 <- glmer(outcome ~ condition + (1|ID), family=poisson, data=dat)
m2: This, I think, still has the random intercept, but also also the condition is random for ID (I found this here: http://lme4.r-forge.r-project.org/book/Ch4.pdf)
m2 <- glmer(outcome ~ condition + (1+condition|ID), family=poisson, data=dat)
m3: I found information that said this was how you told R that condition is nested within ID (and it has a random intercept for each combination of ID and condition, hasn't it?):
m3 <- glmer(outcome ~ condition + (1|ID/condition), family=poisson, data=dat)
m4: And I also found this version:
m4 <- glmer(outcome ~ condition + (1|ID:condition), family=poisson, data=dat)
I have fitted mixed effects models in MLwiN before where you define your levels (ID, condition within ID) and then have to specify the level for each variable you put into the model, but I am not sure how this translates into R. (In case you are wondering, I cannot us R2MLwiN because I do not have an MLwiN license at my new employer's). Also, I have never fitted repeated measures within a mixed effects setup, so maybe my assumption that condition is nested within ID is wrong an it is the subject that is nested within the condition?
I'd be very grateful for any tips and insights on what is the correct syntax to use for my data! Thank you so much and have a nice day!