使用来自混合模型的新数据的simulate.merMod出错

时间:2015-09-30 14:48:30

标签: lme4

我试图从simulate中的glmer模型lme4尝试newdata。我尝试传递# Mixed model gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd), data = cbpp, family = binomial) # Generate new data as per example newdata <- with(cbpp, expand.grid(period=unique(period), herd=unique(herd))) # Predict works as expected predict(gm1, newdata=newdata) # works predict(gm1, newdata=newdata[1,]) # works # Simulate generates different errors simulate(gm1, newdata=newdata) # works with error, but probably fine. # Warning message: # In wts - Y : # longer object length is not a multiple of shorter object length simulate(gm1, newdata=newdata[1,]) # doesn't work # Error in data.frame(sim_1 = c(" 4", "10"), check.names = FALSE, row.names = "1") : # 'row.names' should specify one of the variables # In addition: Warning message: # In format.data.frame(x, digits = digits, na.encode = FALSE) : # corrupt data frame: columns will be truncated or padded with NAs newdata2 = data.frame( herd=c("1"), period=c("1") ) simulate(gm1, newdata=newdata2) # same error simulate(gm1, newdata=newdata[1:2,]) # works but with error # Warning message: # In format.data.frame(x, digits = digits, na.encode = FALSE) : # corrupt data frame: columns will be truncated or padded with NAs ,但是使用各种格式获得了不同的错误。可能只是不了解函数需要什么格式,但包示例也会产生错误。

包数据示例:

R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.1 LTS

other attached packages:
 [1] ggplot2_1.0.0   Zelig_3.5.4     boot_1.3-9      MASS_7.3-29     Hmisc_3.14-5   
 [6] Formula_1.1-2   survival_2.37-7 lattice_0.20-29 plyr_1.8.1      RCurl_1.95-4.3 
[11] bitops_1.0-6    lme4_1.1-10     Matrix_1.1-2   

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.1         cluster_1.14.4      munsell_0.4.2       colorspace_1.2-4   
 [5] minqa_1.2.4         stringr_0.6.2       tools_3.2.1         nnet_7.3-7         
 [9] MatchIt_2.4-21      gtable_0.1.2        nlme_3.1-113        latticeExtra_0.6-26
[13] digest_0.6.4        reshape2_1.4        RColorBrewer_1.0-5  nloptr_1.0.4       
[17] acepack_1.3-3.3     rpart_4.1-5         labeling_0.3        scales_0.2.4       
[21] foreign_0.8-59      proto_0.3-10    
application
system
solution
etc.

1 个答案:

答案 0 :(得分:0)

现在在开发版本lme4中fixed。非常感谢Ben Bolker。

devtools::install_github("lme4/lme4")