错误"'什么'必须是字符串或函数"在R中使用lme4 :: glmer

时间:2014-03-12 16:32:10

标签: r

即使使用lme4 :: glmer:

中的示例,我也收到以下错误消息
>require(lme4)
> (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
+               data = cbpp, family = binomial))
Error in do.call(new, c(list(Class = "glmResp", family = family), ll[setdiff(names(ll),  : 
  'what' must be a character string or a function

我在附近狩猎,无法弄清楚出了什么问题。有人有想法吗?

1 个答案:

答案 0 :(得分:5)

(为了清楚起见,作为答案发布。)

到目前为止我无法重现这一点:我尽可能地尝试复制你的加载包环境。

pkgs <- c("lme4","Matrix","psych","plyr","car",
      "rms","SparseM","Hmisc","Formula","survival",
      "pscl","vcd","gam","coda","lattice",
      "mvtnorm","MASS","gdata","mice","Rcpp",
      "ggplot2","vimcom","setwidth")
sapply(pkgs,library,character.only=TRUE)
sessionInfo()
## attached base packages:
## [1] splines   grid      stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] setwidth_1.0-3   vimcom_0.9-93    ggplot2_0.9.3.1  mice_2.21       
##  [5] Rcpp_0.11.0      gdata_2.13.2     pscl_1.04.4      vcd_1.3-1       
##  [9] gam_1.09.1       coda_0.16-1      mvtnorm_0.9-9997 MASS_7.3-30     
## [13] rms_4.1-3        SparseM_1.03     Hmisc_3.14-3     Formula_1.1-1   
## [17] survival_2.37-7  car_2.0-19       plyr_1.8.1       psych_1.4.2.3   
## [21] lme4_1.0-6       Matrix_1.1-2-2   lattice_0.20-27 
## 
## loaded via a namespace (and not attached):
##  [1] cluster_1.14.4      colorspace_1.2-4    dichromat_2.0-0    
##  [4] digest_0.6.4        gtable_0.1.2        gtools_3.3.1       
##  [7] labeling_0.2        latticeExtra_0.6-26 minqa_1.2.3        
## [10] munsell_0.4.2       nlme_3.1-113        nnet_7.3-7         
## [13] proto_0.3-10        randomForest_4.6-7  RColorBrewer_1.0-5 
## [16] reshape2_1.2.2      rpart_4.1-6         scales_0.2.3       
## [19] stringr_0.6.2       tools_3.1.0        

gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
          data = cbpp, family = binomial)

(工程)。 如果我定义一个名为new的变量:

,我可以打破这个
new <- 123
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
          data = cbpp, family = binomial)

## Error in do.call(new, c(list(Class = "glmResp", family = family), ll[setdiff(names(ll),  : 
##  'what' must be a character string or a function

(我认为这个错误已经在 v.1.0-6中修复了,但我猜它随后被修复了......)

如果我定义一个名为new函数,它会略有不同。 如果我删除new,它会再次起作用(如前所述)。

你可以尝试(1)rm("new")和(2)从干净的会话开始吗?

除非其他人(最好是我)能够重现错误,否则很难修复......