[R-sig-ME] incorrect weights type in lmer
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Tue May 22 22:56:38 CEST 2007
Hi, all,
I'm receiving an error I don't understand regarding a weights argument
to lmer. Here's an example:
library(lme4)
set.seed(1)
tmp.df <- expand.grid(A = factor(1:3), B = 1:3, C = 1:10)
tmp.df$w <- as.integer(rpois(nrow(tmp.df), 50))
tmp.df$p <- 0.5 + with(tmp.df, ifelse(B%%2, -0.1, 0.1))
tmp.df$p <- with(tmp.df, p + ifelse(B%%2 & C%%2, -0.1, 0.1))
tmp.df$y <- rbinom(nrow(tmp.df), tmp.df$w, tmp.df$p)/tmp.df$w
tmp.df[2:3] <- lapply(tmp.df[2:3], factor)
fit <- lmer(y ~ A + (1 | B) + (1 | B:C), tmp.df, binomial, weights = w)
Error in lmer(y ~ A + (1 | B) + (1 | B:C), tmp.df, binomial, weights = w) :
object `weights' of incorrect type
What sort of object is lmer expecting for weights?
> sessionInfo()
R version 2.5.0 (2007-04-23)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
other attached packages:
lme4 Matrix lattice
"0.99875-0" "0.99875-1" "0.15-6"
Thanks,
--sundar
More information about the R-sig-mixed-models
mailing list