0

I have been provided with the following formulas and need to find the correct lme4 code. I find this rather challenging and could not find a good example I could follow...perhaps you can help?

I have two patient groups: group1 and group2. Both groups came to the lab 4 times for testing (4 VISITs) and during each of these visits, their memory was tested 4 times (4 RECALLs). The memory performance should be predicted from Age, Sex and two sleep parameters, which were assessed during each VISIT.

Thus Level 1 should be the RECALL (index i), Level 2 the VISIT (index j) and Level 3 the subject level (index k).

Level 1:

MEMSCOREijk = β0jk + β1jk * RECALLijk + Rijk

Level 2:

 β0jk = γ00k + γ01k * VISITjk + U0jk 
 β1jk = γ10k + γ11k * VISITjk + U1jk

Level 3:

 γ00k = δ000 + δ001 * SLEEPPARAM + V0k 
 γ10k = δ100 + δ101 * SLEEPPARAM + V1k

Thanks so much for your thoughts!

4

1 回答 1

3

像这样的东西应该工作:

lmer(memscore ~ age + sex + sleep1 + sleep2 + (1 | visit) + (1 + sleep1 + sleep2 | subject), data = mydata)

通过添加sleep1sleep2(1 + sleep1 + sleep2 | subject)您将允许两个睡眠参数的影响因参与者而异(随机斜率),并具有随机截距(更多关于下一句)。(1 | visit)将允许对每次访问进行随机截取(随机截取将模拟不同访问具有更高或更低平均 memscore 的数据),但不是随机斜率;我认为您不希望通过访问获得睡眠参数的随机斜率 - 每次访问仅测量一次吗?如果是这样,我相信模型不会有坡度变化。

希望有帮助!我发现这本书非常有用:

Snijders, TAB 和 Bosker, RJ (2012)。多级分析:基本和高级多级建模简介(第 2 版):Sage。

于 2018-11-02T13:36:47.793 回答