## 【原】R数据分析：混合效应模型实例

2021-02-04   |  转藏

# 实例描述

Hypothetical sample size, n = 30

DV: Mood rating (scale)

IV1: Pizza consumption

IV2: Time points (Weeks, 1-10)

# 随机效应与固定效应

Fixed effects are, essentially, your predictor variables. This is the effect you are interested in after accounting for random variability (hence, fixed).

Random effects are best defined as noise in your data. These are effects that arise from uncontrollable variability within the sample. Subject level variability is often a random effect.

# 截距与斜率

Intercepts: The baseline relationship between IV & DV. Fixed effects are plotted as intercepts to reflect the baseline level of your DV.

Slope: The strength of the relationship between IV & DV (controlling for randomness), which represent random effects. You should expect to see differences in the slopes of your random factors.

# 随机效应结构

`(1 + IV | unit level) (1 + IV.1*IV.2 | unit level)#or(0 + IV | unit level)(0 + IV.1*IV.2 | unit level)`

• (1| subject) =每个个体都是随机截距和随机斜率

• (1 + pizza |subject) =不同个体间披萨消费量的影响不同，披萨消费量有随机截距，个体间披萨消费量的影响不同。

• (1 + pizza | subject) + (0 + time| subject)=个体在被披萨消费量影响时有随机截距和随机斜率。时间的斜率也是随机的，但是披萨消费量和时间是独立的。

• (1 + pizza + time | subject) =和上面一样，但是披萨消费量和时间是有共变的

• (1 + pizza * time | subject) =在时间和披萨消费量上每一个个体都有他们的截距和随机斜率，以及披萨消费量和时间的交互，且所以的截距和斜率都有相关。

# 寻找最好的随机效应结构

`nullmodel1 <- lmer( mood ~ 1 + (1|subject), data = pizzadata, REML=FALSE)nullmodel2 <- lmer( mood ~ 1 + (1 + pizza |subject), data = pizzadata, REML=FALSE)nullmodel3 <- lmer( mood ~ 1 + (1 + pizza * time |subject), data = pizzadata, REML=FALSE)``anova (nullmodel1, nullmodel2, nullmodel3)`

# 加入固定效应

`m1=lmer(mood ~ pizza + (1 + pizza + time |subject), data=pizzadata, REML = FALSE)summary(m1)m2= lmer(mood ~ pizza + time + (1 + pizza + time |subject), data=pizzadata, REML = FALSE)summary(m2)m3 = lmer(mood ~ pizza*time + (1 + pizza + time |subject), data=pizzadata, REML = FALSE)summary(m3)`

`anova (m1, m2, m3)`

# 小结

If you are a student and you are worried about you statistical #Assignments, #Data #Analysis, #Thesis, #reports, #composing, #Quizzes, Exams.. And if you are facing problem in #SPSS, #R-Programming, #Excel, Mplus, then contact me. Because I could provide you the best services for your Data Analysis.

Are you confused with statistical Techniques like z-test, t-test, ANOVA, MANOVA, Regression, Logistic Regression, Chi-Square, Correlation, Association, SEM, multilevel model, mediation and moderation etc. for your Data Analysis...??

Then Contact Me. I will solve your Problem...

0条评论