使用LMER()函数的多级分析中的交互项

发布于 2025-01-21 23:30:44 字数 1121 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜兔 2025-01-28 23:30:44

从文档(使用?公式)中:

The * operator denotes factor crossing: a*b interpreted as a+b+a:b.

换句话说a*b添加了ab 和他们的互动。因此,在您的模型中,当您使用收入*注册时,这与收入 +注册 +收入:注册相同。您为每个模型描述的两个版本应给出相同的结果。您可以使用:

lmer(y~ 1 + income*enrollment+ (1|householdID), data=data)

这也描述了相同的模型。

如果您的变量是效果编码的,那么您不需要使用factor,但请注意解释效果。

From the documentation (use ?formula):

The * operator denotes factor crossing: a*b interpreted as a+b+a:b.

In other words a*b adds the main effects of a and b and their interaction. So in your model when you use income*enrollment this is the same as income + enrollment +income:enrollment. The two versions you described for each model should give identical results. You could just have used:

lmer(y~ 1 + income*enrollment+ (1|householdID), data=data)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文