简体   繁体   中英

Is glmmTMB truncated negative binomial family still under development?

I have been implementing some negative binomial hurdle models in the R package glmmTMB and have come across something perplexing about the truncated negative binomial family.

In examining the source for that family argument I have found:

truncated_nbinom2 <- function(link="log") {
    r <- list(family="truncated_nbinom2",
           variance=function(mu,theta) {
               stop("variance for truncated nbinom2 family not yet implemented")
         })
    return(make_family(r,link))
}

I am wondering if this family is still under development (as indicated by the stop command in the variance)?

It is documented as working in the vignette, and I am getting reasonable estimates from the models I have fit using this family (eg simulated data from the model seem sensible). I know many of the authors of the package are on this forum so I hoped someone might be able to clarify.

The truncated_nbinom2 family should work fine for most purposes. Looking through the glmmTMB source code ( grep "\$variance" R/*.R ) the $variance component of the family object is used only:

  • computing Pearson residuals
  • in creating objects to be used by the effects package

You may run into trouble somewhere else in the pipeline, if you're using downstream packages that need to use the expected variance of an object to compute something. But everything else should be fine.

PS I found an expression for this variance and created an issue to remind us to implement it: https://github.com/glmmTMB/glmmTMB/issues/606

PPS this is in the development version now (unfortunately, I'm pretty sure the paper I found only covers truncated NB2, so truncated NB1 may have to wait a while. However, the answer still applies - the absence of a variance function will only cause trouble in a few circumstances, and should never cause subtle trouble...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM