[英]Repeated measures: continuous outcome predicted by continous and categorical predictors
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.
我想这将是一个重复的措施 model 但我不确定。 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 ![]() |
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).
在某些情况下,您还可以拟合随机斜率 model (每个人的斜率不同),但在这种情况下,这没有意义,因为您似乎每个人只有两个观察值(因此,斜率变化的估计会被混淆残差变化:见这里的例子)。
Are your samples always in the order "animal, then human"?您的样本总是按照“动物,然后是人类”的顺序排列吗? If not, you might want to add a subject-level fixed effect of order...
如果没有,您可能需要添加一个主题级别的固定效果的顺序...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.