如何在使用lme4包进行随机效应建模时将counterbalance指定为随机效应?

huangapple go评论52阅读模式
英文:

How to specify counterbalance as random effects when analyzing random-effects modelling using the lme4 package?

问题

我在R中使用lme4包进行多层次建模来分析一个数据集。我进行了一项研究,其中参与者和学习材料的影响是平衡的。参与者经历了两种条件之一:(a) 学习A条件或(b) 学习B条件。一半的参与者通过学习A条件学习材料A,通过学习B条件学习材料B,另一半的参与者则通过学习A条件学习材料B,通过学习B条件学习材料A。

我应该如何在lme4包中指定这种平衡作为随机效应?

英文:

I am analyzing a dataset with multilevel modelling in R using the lme4 package. I conducted a study where The influence of participants and learning materials were counterbalanced. Participants went through either the two conditions: (a) learning A condition or (b) learning B condition. The half of the participants learned material A with learning A and material B with learning B, the other half of the particpants learned material B with learning A condition and material A with learning B condition.

How should I specify this counterbalance as random effect for the lm4 package?

答案1

得分: 1

Participants went through either the two conditions: (a) learning A condition or (b) learning B condition. The half of the participants learned material A with learning A and material B with learning B, the other half of the participants learned material B with learning A condition and material A with learning B condition.

参与者经历了两种条件:(a) 学习 A 条件或 (b) 学习 B 条件。一半的参与者使用学习 A 来学习材料 A,使用学习 B 来学习材料 B,另一半的参与者则使用学习 A 来学习材料 B 条件,使用学习 B 来学习材料 A 条件。

I think the most sensible model for your experimental design corresponds to the mixed-model formula

我认为对于你的实验设计,最合理的模型是混合模型公式

~ material*learning + (1 | subject)

这意味着你可以在总体水平上估算材料和学习条件之间的交互作用,但只能在各个主体之间估算在学习效果(或你正在测量的任何其他指标)上的整体差异。我最初认为你可以估算学习和材料的加法效应在主体之间的差异,但这有点棘手,因为每个个体只看到两种条件(A/A,B/B B/A,A/B)(要估算材料和学习的加法效应方差需要每个个体有三种处理条件)。你可以估算个体间在他们经历的两种条件之间的差异,但这也很棘手,因为有两种不同类型的条件。如果你想要编码最大模型(Barr et al 2013),假设你有一个 type 变量,用于标识个体是看到 'parallel'(AA,BB)还是 'crossed'(AB,BA)条件,以及一个 which 变量,用于标识个体的试验是在第一个(AA/AB)还是第二个(BB/BA)条件上。

your_data <- transform(your_data,
    tp = dummy(type, 'parallel'),
    tc = dummy(type, 'crossed'))
~ material*learning + 
   (0 + tp + tp:which | subject ) +
   (0 + tc + tc:which | subject)

虚拟变量确保每个随机效应项对于一半的个体为零。这估算了每种类型的不同个体间的效应;这不是完美的,但它避免了其他挑战。如果我们使用 (1 + tp:which + tc:which | subject),我们将尝试估算竖线左侧的第二和第三项之间的相关性,这是不可能的:如果我们使用 (1|subject) + (0 + tp:which | subject) + (0 + tc:which | subject),我们将消除截距和 which 效应之间的相关性,这是一个合理但稍微受限制的假设。

英文:

> Participants went through either the two conditions: (a) learning A condition or (b) learning B condition. The half of the participants learned material A with learning A and material B with learning B, the other half of the participants learned material B with learning A condition and material A with learning B condition.

I think the most sensible model for your experimental design corresponds to the mixed-model formula

~ material*learning + (1 | subject)

That is, you can estimate the interaction between material and learning condition at the population level, but you can only estimate the variation among subjects in overall difference in learning effectiveness (or whatever it is that you're measuring). I initially thought you could estimate the among-subject variation in the additive effects of learning and material, but it's tricky because each individual only sees two conditions (A/A, B/B or B/A, A/B) (estimating variation in the additive effect of both material and learning would require three treatment conditions per individual). You can estimate among-individual variation in the difference between the two conditions they experience, but it's tricky because there are two different types of condition. If you want to go to the effort of coding the maximal model (Barr et al 2013), supposing you have a type variable that identifies subjects as seeing either a 'parallel' (AA, BB) or 'crossed' (AB, BA) set of conditions, and a which variable that identifies whether a trial is on the first (AA/AB) or second (BB/BA) condition for that individual.

your_data <- transform(your_data,
    tp = dummy(type, 'parallel'),
    tc = dummy(type, 'crossed'))
~ material*learning + 
   (0 + tp + tp:which | subject ) +
   (0 + tc + tc:which | subject)

The dummy variable makes sure that each random effect term is zeroed out for half the individuals. This estimates different among-individual terms for each type; this isn't perfect, but it avoids other challenges. If we used (1 + tp:which + tc:which | subject) we would be trying to estimate a correlation between the second and third terms to the left of the bar, which is impossible: if we used (1|subject) + (0 + tp:which | subject) + (0 + tc:which | subject) we would be eliminating the correlation between intercept and which effect, which is a reasonable but slightly restrictive assumption.

huangapple
  • 本文由 发表于 2023年4月7日 00:15:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75951641.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定