在LME模型中,第0级,第1块背推中存在奇异性。

8

dput用于数据传输,从https://pastebin.com/1f7VuBkx复制(太大无法在此处包含)

data.frame':    972 obs. of  7 variables:
$ data_mTBS : num  20.3 22.7 0 47.8 58.7 ...
$ data_tooth: num  1 1 1 1 1 1 1 1 1 1 ...
$ Adhesive  : Factor w/ 4 levels "C-SE2","C-UBq",..: 2 2 2 2 2 2 2 2 2 2 ...
$ Approach  : Factor w/ 2 levels "ER","SE": 1 1 1 1 1 1 1 1 1 1 ...
$ Aging     : Factor w/ 2 levels "1w","6m": 1 1 1 1 1 1 2 2 2 2 ...
$ data_name : Factor w/ 40 levels "C-SE2-1","C-SE2-10",..: 11 11 11 11 11 11 11 11 11 11 ...
$ wait      : Factor w/ 2 levels "no","yes": 1 1 1 1 1 1 1 1 1 1 ...
head(Data)


   data_mTBS data_tooth Adhesive Approach Aging data_name wait
1     20.27          1    C-UBq       ER    1w   C-UBq-1   no
2     22.73          1    C-UBq       ER    1w   C-UBq-1   no
3      0.00          1    C-UBq       ER    1w   C-UBq-1   no
4     47.79          1    C-UBq       ER    1w   C-UBq-1   no
5     58.73          1    C-UBq       ER    1w   C-UBq-1   no
6     57.02          1    C-UBq       ER    1w   C-UBq-1   no

当我运行以下代码时,没有包含“wait”,它可以完美地工作,但是当我尝试在模型中包含“wait”时,它会出现奇异性问题。
LME_01<-lme(data_mTBS ~ Adhesive*Approach*Aging*wait, na.action=na.exclude,data = Data, random = ~ 1|data_name);

MEEM(object, conLin, control$niterEM)中的错误: 在0级、第1个块的backsolve中发生奇异性

contrast_Aging<-contrast(LME_01,a = list(Aging =c("1w"),Adhesive = levels(Data$Adhesive),Approach = levels(Data$Approach) ),b = list(Aging =c("6m"), Adhesive = levels(Data$Adhesive),Approach = levels(Data$Approach)))

c1<-as.matrix(contrast$X)
Contrastsi2<-summary(glht(LME_01, c1))

&

contrast_Approach<-contrast(LME_01,
                                    a = list(Approach = c("SE"), Aging =levels(Data$Aging)   ,Adhesive = levels(Data$Adhesive)),
                                    b = list(Approach = c("ER"), Aging =levels(Data$Aging)   ,Adhesive = levels(Data$Adhesive)))

c2<-as.matrix(contrast$X)
Contrastsi3<-summary(glht(LME_01, c2))

谢谢您的先行支持。


请检查您的数据中是否确实同时包含了 wait=no 和 yes。 - Hong Ooi
@HongOoi,“no”仅适用于“Adhesive”的一个级别;C-UBq。其他三个级别的“Adhesive”正在等待“yes”。 - Mohammed Ahmed
那么... wait 真的能告诉你任何 adhesive 没有告诉你的吗? - Hong Ooi
是的,它与老化和方法一样重要。 - Mohammed Ahmed
实际上不是这样,我添加它是因为当比较SE:ER和比较1w到6m时我得到了相同的对比度。我已经编辑了帖子并加入了对比代码。谢谢您的帮助。 - Mohammed Ahmed
1个回答

17

简而言之(tl;dr) 正如 @HongOoi 所告诉您的那样,您的模型中 waitAdhesive 是混淆的。相较于R中其他建模函数,lme 较为愚钝/顽固,它要么明确警告您固定效应被混淆,要么自动为您删除其中一些。

如果绘制数据,则更容易看到这一点:

## source("SO50505290_data.txt")

library(ggplot2)
ggplot(dd,aes(Adhesive,data_mTBS,
              fill=Aging,
              alpha=Approach))+
  facet_grid(.~wait,scale="free_x",space="free",
             labeller=label_both)+
  guides(alpha = guide_legend(override.aes = list(fill = "darkgray")))+
  geom_boxplot()
ggsave("SO50505290.png")

输入图像描述

这说明知道 wait=="no" 就等于知道 Adhesive=="C-UBq"

回到问题本身可能会更有意义,但如果你使用 lme4::lmer 进行操作,它将告诉你:

 

fixed-effect model matrix is rank deficient so dropping 16 columns / coefficients

library(lme4)
LME_02<-lmer(data_mTBS ~ Adhesive*Approach*Aging*wait+
               (1|data_name), 
            na.action=na.exclude,data = dd)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接