简体   繁体   English

R-从glmmadmb输出中提取过分散参数

[英]R - Extract overdispersion parameter from glmmadmb output

I'm wondering if anyone knows of a way to extract the estimate for the dispersion parameter from the output of glmmadmb in R. I'm using a negative binomial model, and would like to use this code for several different species without having to go in and manually extract this value for the remainder of the code. 我想知道是否有人知道从R中glmmadmb的输出中提取色散参数的估计值的方法。我使用的是负二项式模型,并且想将此代码用于几种不同的物种而不必输入并手动提取其余代码的值。

This is an example of my output: 这是我的输出示例:

  > summary(mod1)

       Call:
           glmmadmb(formula = species ~ (1 | year) + (1 | site), data = cs, 
           family = "nbinom2", link = "log")

        AIC: 8131.7 

       Coefficients:
        Estimate Std. Error z value Pr(>|z|)    
        (Intercept)     4.05       0.19    21.3   <2e-16 ***
          ---
         Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

       Number of observations: total=798, year=53, site=15 
       Random effect variance(s):
       Group=year
                  Variance StdDev
       (Intercept)   0.1925 0.4388
       Group=site
                  Variance StdDev
       (Intercept)   0.4748  0.689

       Negative binomial dispersion parameter: 1.7211 (std. err.: 0.088936)

       Log-likelihood: -4061.86 

I haven't found a function that extracts this value. 我还没有找到提取此值的函数。

Thank you in advance! 先感谢您!

The help page for glmmadmb , says, among other things: glmmadmb的帮助页面包括:

Value: 值:

  An object of class '"glmmadmb"' representing the model fit, including (among others) components: b: vector of fixed effects S: covariance matrix of random effects 

alpha: scale/overdispersion parameter (negative binomial, Gamma, beta) alpha:比例/过度分散参数(负二项式,Gamma,beta)

So I think mod1$alpha (or mod1[["alpha"]] if you want to be very careful) should get what you want. 因此,我认为mod1$alpha (或者如果要非常小心,可以使用mod1[["alpha"]]应该可以得到想要的。

If the documentation weren't there, you could (1) look at the code of glmmADMB:::print.summary.glmmadmb as suggested by @DWin ; 如果文档不存在,您可以(1)查看glmmADMB:::print.summary.glmmadmb建议的glmmADMB:::print.summary.glmmadmb代码; (2) look at names(mod1) , or str(mod1) , to find the piece of the model object that corresponded to the piece you wanted. (2)查看names(mod1)str(mod1) ,以找到与所需零件相对应的模型对象零件。

There probably should be an accessor method, but I don't know that there's a consistent convention in R for extracting dispersion-type parameters for models ... 可能应该有一个访问器方法,但我不知道R中有一个一致的约定来提取模型的分散类型参数...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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