我的因变量
st
的分布遵循 Beta 分布(通过命令 descdist
可见)。现在我必须创建我的模型。
唯一的问题是我的实验设计是 3x2,其中我有一个名为 temp
的 IV,一个在参与者(不同时间的同一参与者)内测量 3 个水平的因子,以及一个名为 cond
的 IV,一个具有 3 个水平的因子2 个水平作为参与者之间的效应(两个不同的组)进行测量。我想同时看到主效应和交互效应。
到目前为止,我已经在用 betareg()
拟合分布后应用了 fitdist()
公式来进行 beta 分布。唯一的问题是,我不知道如何在 betareg()
公式中表明我的临时变量是 within,而我的 cond
变量是 Between 主题。你能帮我吗?
我尝试应用这个公式:
MSTb=betareg(scaledst~temp*cond, data=ds.cy)
然后方差分析
Anova(MSTB)
它给了我一个结果,但我认为它没有考虑重复测量的情况。
应用这个公式是行不通的:
MSTb=betareg(scaledst~temp*cond+(1|id), data=ds.cy)
其中“id”是要过滤的参与者的代码。它给了我这个错误:Error in
`contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
the contrast can be applied only to factors variable with 2 or more levels
In addition: Warning message:
In Ops.factor(1, id) : ‘|’ not meaningful for factors
这个都不是:
betareg(scaledst~temp*cond+(1+temp|id), data=ds.cy)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
In addition: Warning messages:
1: In Ops.factor(1, temp) : ‘+’ not meaningful for factors
2: In Ops.factor(1 + temp, id) : ‘|’ not meaningful for factors
betareg
不处理混合模型/随机效果,因此它的公式处理器变得混乱。你可以试试glmmTMB
:
library(glmmTMB)
MSTb <- glmmTMB(scaledst~temp*cond+(1|id), data=ds.cy, family = beta_family)
由于
temp
是一个受试者内变量,并且您有两个以上水平(因此受试者内变异不会与残余变异混淆),您可以尝试
scaledst~temp*cond+(temp|id)
考虑受试者之间温度效应的差异。
我相信
GLMMadaptive
和 brms
包也可以处理具有 Beta 分布式响应的混合模型(尽管 混合模型任务视图 在这方面不太清楚......)
PS,使用
descdist
和 fitdist
来表征响应的 marginal(整体)分布并没有什么意义;您需要评估数据的条件分布是否足够好地遵循某些特定的假设分布...