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

前端 未结 2 800
太阳男子
太阳男子 2021-02-06 16:53

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 argume

2条回答
  •  青春惊慌失措
    2021-02-06 17:41

    There are basically two (simple) confusions here.

    • The first is between coef() (which returns a list of matrices) and fixef() (which returns a vector of the fixed-effect coefficients): I assume that fixef() is what you wanted, although you might want something like c(fixef(mixed),unlist(VarCorr(mixed))).
    • the second is that FUN should take a fitted model object as 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
    ## 
    

提交回复
热议问题