User-defined link function for glmer for known-fate survival modeling

后端 未结 1 528
天命终不由人
天命终不由人 2021-01-03 13:50

A common situation in ecology is a survival model with a binary outcome (0=die, 1=survive) where individuals (for this example think of individual nesting attempts by birds)

1条回答
  •  -上瘾入骨i
    2021-01-03 14:17

    You need to use a more recent version of the lme4 package, e.g. the 1.0-4 version that has just gone up on CRAN. Earlier versions did not allow user-specified link functions.

    Also, note that the code you posted above is not what appears in recent versions of ?family, where the (obsolete) .Call("logit_mu_eta", eta, PACKAGE = "stats") is replaced by a pure-R implementation:

    logexp <- function(days = 1)
         {
             linkfun <- function(mu) qlogis(mu^(1/days))
             linkinv <- function(eta) plogis(eta)^days
             mu.eta <- function(eta) days * plogis(eta)^(days-1) * binomial()$mu_eta
             valideta <- function(eta) TRUE
             link <- paste0("logexp(", days, ")")
             structure(list(linkfun = linkfun, linkinv = linkinv,
                            mu.eta = mu.eta, valideta = valideta, name = link),
                       class = "link-glm")
         }
    

    The link you specified above, http://rpubs.com/bbolker/4082 , does in fact have an example of such a model (but it does require a recent version of lme4).

    0 讨论(0)
提交回复
热议问题