lme4 - Errors with simulate.merMod with new data from mixed model -


i'm trying simulate glmer model in lme4. i'm trying pass newdata getting different errors various formats. not understanding format function needs, package examples generate errors.

example package data:

# mixed model gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),               data = cbpp, family = binomial)  # generate new data per example newdata <- with(cbpp, expand.grid(period=unique(period), herd=unique(herd)))  # predict works expected predict(gm1, newdata=newdata)                # works predict(gm1, newdata=newdata[1,])            # works  # simulate generates different errors simulate(gm1, newdata=newdata)               # works error, fine. # warning message: #   in wts - y : #   longer object length not 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 1 of variables # in addition: warning message: #   in format.data.frame(x, digits = digits, na.encode = false) : #   corrupt data frame: columns truncated or padded nas  newdata2 = data.frame(   herd=c("1"),   period=c("1") ) simulate(gm1, newdata=newdata2)              # same error  simulate(gm1, newdata=newdata[1:2,])         # works error # warning message: #   in format.data.frame(x, digits = digits, na.encode = false) : #   corrupt data frame: columns truncated or padded 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 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     

this fixed in development version lme4. many ben bolker.

devtools::install_github("lme4/lme4")


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -