Monday, 26 August 2013

R: Bootstrapped binary mixed-model logistic regression using bootMer() of the new lme4 package

R: Bootstrapped binary mixed-model logistic regression using bootMer() of
the new lme4 package

I want to use the new bootMer() feature of the new lme4 package (the
developer version currently). I am new to R and don't know which function
should I write for its FUN argument. It says it needs a numerical vector,
but I have no idea what that function will perform. So I have a
mixed-model formula which is cast to the bootMer(), and have a number of
replicates. So I don't know what that external function does? Is it
supposed to be a template for bootstrapping methods? Aren't bootstrapping
methods already implemented in he bootMer? So why they need an external
"statistic of interest"? And which statistic of interest should I use?
Is the following syntax proper to work on? R keeps on error generating
that the FUN must be a numerical vector. I don't know how to separate the
pure estimates from the "fit" and even should I do that in the first
place? coef(fit) returns a mostly numerical vector, but not a pure one. I
can just say I am lost with that "FUN" argument. Also I don't know should
I pass the mixed-model glmer() formula using the variable "Mixed5" or
should I pass some pointers and references? I see in the examples that X
(the first argument of bootMer() is a *lmer() object. I wanted to write
*Mixed5 but it rendered an error.
Many thanks.
My code is:
library(lme4)
library(boot)
(mixed5 <- glmer(DV ~ (Demo1 +Demo2 +Demo3 +Demo4 +Trt)^2
+ (1 | PatientID) + (0 + Trt | PatientID)
, family=binomial(logit), MixedModelData4))
FUN <- function(formula) {
fit <- glmer(DV ~ (Demo1 +Demo2 +Demo3 +Demo4 +Trt)^2
+ (1 | PatientID) + (0 + Trt | PatientID)
, family=binomial(logit), MixedModelData4)
return(coef(fit))
}
result <- bootMer(mixed5, FUN, nsim = 3, seed = NULL, use.u = FALSE,
type = c("parametric"),
verbose = T, .progress = "none", PBargs = list())
result
FUN
fit
And the error:
Error in bootMer(mixed5, FUN, nsim = 3, seed = NULL, use.u = FALSE, type =
c("parametric"), :
bootMer currently only handles functions that return numeric vectors

No comments:

Post a Comment