使用LMER()函数的多级分析中的交互项
1级变量:
income - continuous
级别2变量:
state's general whether: three leveled categorical variable: hot/moderate/cool
used effect coded, and generate two variables because it has three levels.
(weather_ef1, weather_ef2)
enrolled in university - binary : yes/no ( effect coded. yes = -1, no =1)
DV: 数学分数
分组变量:家庭
模型1 :(固定斜率)
DV通过收入,入学率以及入学和收入之间的相互作用预测。 在这种情况下,
lmer(y~ 1 + income + enrollment +income*enrollment+ (1|householdID), data=data)
lmer(y~ 1 + income + enrollment +income:enrollment+ (1|householdID), data=data)
:是用于互动吗?还是 *是为了互动吗?
此外,我必须做因素(入学)吗? 还是可以,因为已经对其进行了编码?
模型2 :(固定的坡度)
DV通过收入,天气以及收入和天气之间的互动预测,
lmer( y ~ 1 + income + weather_ef1 + weather_ef2 + weather_ef1*income
+ weather_ef2*income +(1|houshold_id), data)
lmer ( y ~ l + income + weather_ef1+ weather_ef2 + weather_ef1:income
+ weather_ef2:income + (1|houshold_id), data)
仍然令人困惑 *是正确的,或者是正确的。
我认为效果代码变量已经被编码了,所以我不必 请使用因子(Weather_EF1)的东西。
level 1 variable:
income - continuous
level 2 variable:
state's general whether: three leveled categorical variable: hot/moderate/cool
used effect coded, and generate two variables because it has three levels.
(weather_ef1, weather_ef2)
enrolled in university - binary : yes/no ( effect coded. yes = -1, no =1)
DV:
math score
grouping variable: household
model 1: (fixed slope)
Dv is predicted by income, enrollment, and the interaction between enrollment and income.
in this case,
lmer(y~ 1 + income + enrollment +income*enrollment+ (1|householdID), data=data)
lmer(y~ 1 + income + enrollment +income:enrollment+ (1|householdID), data=data)
: is it for interaction? or * is it for interaction?
further, do I have to do factor(enrollment)?
or is it okay because it is already effect coded?
model 2: (fixed slope)
DV is predicted by income, weather, and interaction between income and weather
lmer( y ~ 1 + income + weather_ef1 + weather_ef2 + weather_ef1*income
+ weather_ef2*income +(1|houshold_id), data)
lmer ( y ~ l + income + weather_ef1+ weather_ef2 + weather_ef1:income
+ weather_ef2:income + (1|houshold_id), data)
Still confusing * is right or: is right.
I think the effect code variables are already effect coded, so I don't have to
do use the factor(weather_ef1) things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从文档(使用
?公式
)中:换句话说
a*b
添加了a
和b 和他们的互动。因此,在您的模型中,当您使用
收入*注册
时,这与收入 +注册 +收入:注册
相同。您为每个模型描述的两个版本应给出相同的结果。您可以使用:这也描述了相同的模型。
如果您的变量是效果编码的,那么您不需要使用
factor
,但请注意解释效果。From the documentation (use
?formula
):In other words
a*b
adds the main effects ofa
andb
and their interaction. So in your model when you useincome*enrollment
this is the same asincome + enrollment +income:enrollment
. The two versions you described for each model should give identical results. You could just have used:which also describes the same model.
If your variables are effect coded then you don't need to use
factor
but be careful about the interpretation of the effects.