为什么在glm上计算事后测试时会收到这些错误消息

时间:2019-01-25 09:38:21

标签: r glm posthoc tukey

我想在glm上计算事后测试,但一直遇到错误消息。我正在运行的代码如下:

  # Read data
  read.table("adult_pref.txt")

  # Assign a name to the data
  epi <- read.table("adult_pref.txt", 
                     ,col.names=c('generation','preference','A','B'),
                     header=TRUE, sep="\t", na.strings="NA", dec=".", strip.white=TRUE)

  glm <- glm(cbind(A,B)~generation, data=epi, family=quasibinomial(link="logit"))
  anova(glm, test="Chisq")
  library(multcomp)

  pref.test <- glht(glm, linfct=mcp(preference="Tukey"))
summary(pref.test)

我在运行pref.test <- glht(glm, linfct=mcp(preference="Tukey"))时遇到以下错误:

    Error in mcp2matrix(model, linfct = linfct) : 
  Variable(s) ‘preference’ have been specified in ‘linfct’ but cannot be found in ‘model’! 

似乎R不能在模型中找到可变参数偏好。只是让您了解我的数据的样子:

             V1           V2          V3          V4
1   generation   preference      A            B
2           F0        -0.43 28.47457627 71.52542373
3           F0        -0.82 9.150326797  90.8496732
4           F0           -1           0         100
5           F0        -0.38 30.83832335 69.16167665
6           F0           -1           0         100

有人知道我在做什么错吗?

0 个答案:

没有答案