I have conducted a research in which the experimental design is 2x2.
我进行了一项研究,其中的实验设计是2x2。
I have a independent variable called strum
which is a two-level factor and is within participants (so same participants in two different times). Then I have another independent variable called cond
which is also a two-level factor and is instead treated as a between-subjects variable (so two different groups).
I would like to apply a lmer
and a glm
or glmer
formula to fit the model and then apply an Anova, considering also the interaction effect. How can I write down the formula? How would be the syntax of it?
我有一个名为strum的自变量,它是一个两级因素,在参与者中(所以相同的参与者在两个不同的时间)。然后我有另一个自变量,叫做cond,它也是一个两级因子,而不是被视为受试者之间的变量(所以是两个不同的组)。我想应用LMER和GLM或GLMER公式来拟合模型,然后应用方差分析,同时考虑到相互作用的影响。我怎么才能写下公式呢?它的语法会是怎样的?
I tried with this formula:
我试着用这个公式:
minv=lmer(pqinvolv~(strum*cond|pqinvolv)+(strum|id), data=dv_n)
where pqinvolv
is the dependent variable, but it gives me an error
其中,pqinventv是因变量,但它给了我一个错误
and also this one:
还有这一张:
minv=lmer(pqinvolv~strum*cond+(1|id), data=dv_n)
while this one works, but I'm not sure it consider my IV as a mixed model or just a two way repeated measure with all the variables being measured as within-subjects.
虽然这个方法有效,但我不确定它是否认为我的IV是一个混合模型,或者只是一个双向重复测量,所有变量都作为受试者内部测量。
更多回答
Can you edit your question to include the error message you get?
您可以编辑您的问题以包括您收到的错误消息吗?
优秀答案推荐
Based on your description,
根据你的描述,
pqinvolv ~ strum*cond + (1 + strum|id)
would be an appropriate model: strum*cond
(which expands to 1 + strum + cond + strum:cond
) specifies the main effects of strum
and cond
and their interaction at the population level, while 1 + strum|id
allows the effect of strum
to vary among participants. You can't include cond
in the random effect because it's unidentifiable (i.e., since it's a between-subjects factor, you can't tell how its effect varies between subjects). (I can't think of any scenario where putting the dependent variable (pqinvolv
) anywhere on the right side of the formula makes sense.)
将是一个合适的模型:strum*cond(扩展为1+strum+cond+strum:cond)指定strum和cond的主要效果以及它们在种群水平上的交互作用,而1+strum|id允许strum的效果因参与者而异。你不能在随机效果中包含cond,因为它是不可识别的(即,因为它是主体间的因素,你不能知道它的效果在不同主体之间有什么不同)。(我想不出有什么场景可以将因变量(Pqinventv)放在公式右侧的任何位置。)
However, since you only have two levels of strum
, the among-subject variation in strum
effect is confounded with the residual variance, so you should simplify your model to
但是,由于您只有两个级别的strum,所以strum效果中的主体间差异与残差方差混淆,因此您应该简化您的模型以
pqinvolv ~ strum*cond + (1|id)
(This assumes you are fitting a linear mixed model, not a generalized linear mixed model with a fixed scale parameter, e.g. for Poisson or binomial responses.)
(这假设您拟合的是线性混合模型,而不是具有固定比例参数的广义线性混合模型,例如泊松或二项响应。)
A similar situation is described in the "starling example" here.
类似的情况在这里的《八哥范例》中也有描述。
更多回答
I'm very thankful for your reply and you tryina helping me. I have tried with the formula you wrote down, but once I run it, ti gives me this kind of error: Error: number of observations (=96) <= number of random effects (=96) for term (1 + strum | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable Which I think is a matter of observation since strum is as factor with 2 levels cond is as factor with 2 levels id is as factor with 48 levels. the total amount of obs are 96, which meant there were 48 participants
我非常感谢你的回复和你试图帮助我。我试过你写下的公式,但一旦我运行它,ti给我这样的错误:Error:观察次数(=96)<=项(1+strum|id)的随机效果数(=96);随机效果参数和残差方差(或比例参数)可能无法识别,我认为这是观察的问题,因为strum是2级条件的因素,id是48水平的因素。OB的总数为96个,这意味着有48个参与者
我是一名优秀的程序员,十分优秀!