Reputation: 53
I have the following variables and if they were in wide format I would calculate something like
lm(happiness ~ personality_trait*condition)
But my data is in long format. I suppose it will be a repeated measures model but I'm not sure. I considered Linear Mixed Models but I'm not sure if I understood and whether it is what I'm looking for.
Thanks a lot!
participant | personality_trait1 | condition | happiness |
---|---|---|---|
1 | 10 | animal | 5 |
1 | 10 | human | 7 |
2 | 2 | animal | 3 |
2 | 2 | human | 4 |
3 | 5 | animal | 6 |
3 | 5 | human | 2 |
Upvotes: 2
Views: 377
Reputation: 226097
I think
library(lme4)
lmer(happiness ~ personality_trait*condition + (1|participant), data= ...)
should do it. This allows for a different intercept for each individual, drawn from a Gaussian distribution around the population mean intercept). In some situations you could also fit a random slopes model (different slope for each individual), but in this case it wouldn't make sense since you appear to have only two observations per individual (thus, estimates of variation in slope would be confounded with the residual variation: see here for an example).
Are your samples always in the order "animal, then human"? If not, you might want to add a subject-level fixed effect of order ...
Upvotes: 2