【问题标题】:Error in UseMethod("cld") : no applicable method for 'cld' applied to an object of class "c('emm_list', 'list')"UseMethod(“cld”)中的错误:没有适用于“cld”的适用方法应用于类“c('emm_list','list')”的对象
【发布时间】:2019-09-23 09:32:00
【问题描述】:

尝试运行

cld(posthoc, alpha=.05, Letters=letters)

获取我的数据的字母值的代码,但产生此错误:

UseMethod("cld") 中的错误: 没有适用于“cld”的方法应用于“c('emm_list', 'list')”类的对象

arcdata

代码如下

install.packages("car")
arcdata<- read.csv(file.choose()) 
arcdata
dput(arcdata)
str(arcdata)
library(ggpubr)
plot<- ggline(arcdata, x="preg", y="arc", color = "herd",
    add =c("mean_se", "dotplot"), palette= c("#00AFBB", "#E7B800"))
plot


model1<-lm(arc~herd*preg, data = arcdata)
anova(model1)

plot(model1, 2)

aov_residuals<-residuals(object = model1)
shapiro.test(aov_residuals)


plot(model1, 1)
leveneTest(arc~herd*preg, data= arcdata)

install.packages("lsmeans")
install.packages("multcompView")
library("lsmeans")
library("multcompView")

posthoc<-lsmeans(model1, pairwise~herd*preg, adjust="tukey")
posthoc

cld(posthoc, 
    alpha=.05,
    Letters=letters)

代码的最后(cld)部分没有生成预期的字母组,这可能与 alpha=.05 有关吗?

【问题讨论】:

  • 我认为cld(posthoc[[1]]) 会起作用。

标签: r


【解决方案1】:
posthoc<-emmeans(model1, pairwise~herd*preg, adjust="tukey")

查看 'posthoc' 的输出,你会发现两个部分($emmeans 和 $contrasts)。 或者您可以使用names(posthoc) 获取。

contrasts 不应包含在其中

所以使用:

CLD(posthoc$emmeans, 
    alpha=.05,
    Letters=letters)

【讨论】:

    【解决方案2】:

    试试这个:

    posthoc<-lsmeans(model1, ~herd*preg, adjust="tukey")
    

    【讨论】:

    • 你能详细说明原因吗?
    • 这似乎是由于 lsmeans 到 emmeans 的转换,以及成对比较。如果您在 herd 或 preg 上运行 cld() 它应该可以工作,但尝试测试交互效果似乎失败了。
    猜你喜欢
    • 1970-01-01
    • 2023-01-22
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 2019-09-12
    • 2022-12-15
    • 2021-07-23
    相关资源
    最近更新 更多