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


i want use new bootmer() feature of new lme4 package (the developer version currently). new r , don't know function should write fun argument. says needs numerical vector, have no idea function perform. have mixed-model formula cast bootmer(), , have number of replicates. don't know external function does? supposed template bootstrapping methods? aren't bootstrapping methods implemented in bootmer? why need external "statistic of interest"? , statistic of interest should use?

is following syntax proper work on? r keeps on error generating fun must numerical vector. don't know how separate estimates "fit" , should in first place? can lost "fun" argument. don't know should pass mixed-model glmer() formula using variable "mixed5" or should pass pointers , references? see in examples x (the first argument of bootmer() *lmer() object. wanted write *mixed5 rendered 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 error:

error in bootmer(mixed5, fun, nsim = 3, seed = null, use.u = false, type = c("parametric"),  :    bootmer handles functions return numeric vectors 

-------------------------------------------------------- update -----------------------------------------------------

i edited code ben instructed. code ran ses , biases zero. know how extract p values output (strange me)? should use mixed() of afex package?

my revised code:

library(lme4) library(boot)  (mixed5 <- glmer(dv ~ (demo1 +demo2 +demo3 +demo4 +trt)^2                  + (0 + trt | patientid)                  , family=binomial(logit), mixedmodeldata4))   fun <- function(fit) {   fit <- glmer(dv ~ (demo1 +demo2 +demo3 +demo4 +trt)^2                 + (1 | patientid) + (0 + trt | patientid)                , family=binomial(logit), mixedmodeldata4)   return(fixef(fit)) }  result <- bootmer(mixed5, fun, nsim = 3)  result 

-------------------------------------------------------- update 2 -----------------------------------------------------

i tried following code generated warnings , didn't give result.

(mixed5 <- glmer(dv ~ demo1 +demo2 +demo3 +demo4 +trt                   + (1 | patientid) + (0 + trt | patientid)                  , family=binomial(logit), mixedmodeldata4))  fun <- function(mixed5) {   return(fixef(mixed5))}  result <- bootmer(mixed5, fun, nsim = 2) 

warning message:

in bootmer(mixed5, fun, nsim = 2) : bootstrap runs failed (2/2) > result  call: bootmer(x = mixed5, fun = fun, nsim = 2)  bootstrap statistics : warning: values of t1* na warning: values of t2* na warning: values of t3* na warning: values of t4* na warning: values of t5* na warning: values of t6* na 

-------------------------------------------------------- update 3 -----------------------------------------------------

this code generated warnings:

fun <- function(fit) {   return(fixef(fit))}  result <- bootmer(mixed5, fun, nsim = 2) 

the warnings , results:

warning message: in bootmer(mixed5, fun, nsim = 2) : bootstrap runs failed (2/2) > result  call: bootmer(x = mixed5, fun = fun, nsim = 2)  bootstrap statistics : warning: values of t1* na warning: values of t2* na warning: values of t3* na warning: values of t4* na warning: values of t5* na warning: values of t6* na 

there 2 (simple) confusions here.

  • the first between coef() (which returns list of matrices) , fixef() (which returns vector of fixed-effect coefficients): assume fixef() wanted, although might want c(fixef(mixed),unlist(varcorr(mixed))).
  • the second fun should take fitted model object input ...

for example:

library(lme4) library(boot)  mixed <- glmer(incidence/size ~ period + (1|herd),                weights=size, data=cbpp, family=binomial)  fun <- function(fit) {     return(fixef(fit)) }  result <- bootmer(mixed, fun, nsim = 3)  result  ## call: ## bootmer(x = mixed, fun = fun, nsim = 3) ## bootstrap statistics : ##      original      bias    std. error ## t1* -1.398343 -0.20084060  0.09157886 ## t2* -0.991925  0.02597136  0.18432336 ## t3* -1.128216 -0.03456143  0.05967291 ## t4* -1.579745 -0.08249495  0.38272580 ##  

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -