【问题标题】:Interpretation of Negative Binomial regression with interaction, offset term and sum contrasts负二项式回归与交互作用、偏移项和总和对比的解释
【发布时间】:2020-11-26 20:39:45
【问题描述】:

我对 R 非常陌生,并且在理解我的总和对比负二项式回归的输出时遇到了问题,无论是否存在两个因素(分类)之间的相互作用。也许有人可以帮忙!

我的因变量是物种数量(观察)。 我包括了一个抵消项来解释不同的“样本”工作。 我的两个(分类)因素是栖息地类型(3 个级别)和时期(2 个级别)。 我使用 sum contrasts 来集中我的因素以与“大均值”进行比较。

我对这个问题感兴趣,如果时期改变/影响物种的栖息地利用。

首先我运行了一个仅包含因子栖息地的模型:

contrasts(counts$habitat) =contr.sum(3,base=1,contrasts=TRUE)
nb_reg<-glm.nb(formula=counts~habitat+offset(log(obs)),data=speciescounts)
summary(nb_reg)

Call:
glm.nb(formula = counts ~ habitat + offset(log(obs)), data = speciescounts, 
    init.theta = 0.4115369822, link = log)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3610  -1.0464  -0.8868   0.1151   4.9992  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)   -2.8424     0.1968 -14.440  < 2e-16 ***
habitat1       0.5624     0.2163   2.600  0.00931 ** 
habitat3      -0.1403     0.2218  -0.633  0.52701    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for Negative Binomial(0.4115) family taken to be 1)

    Null deviance: 230.15  on 254  degrees of freedom
Residual deviance: 219.83  on 252  degrees of freedom
AIC: 759.4

Number of Fisher Scoring iterations: 1


              Theta:  0.4115 
          Std. Err.:  0.0641 

 2 x log-likelihood:  -751.3990

为了获得“缺失”的栖息地类型 2,我更改了对比代码中的基数,得到了以下输出:

Call:
glm.nb(formula = counts ~ habitat + offset(log(obs)), data = speciescounts, 
    init.theta = 0.4115369822, link = log)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3610  -1.0464  -0.8868   0.1151   4.9992  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -2.8424     0.1968 -14.440   <2e-16 ***
habitat2       -0.4221     0.3695  -1.142    0.253    
habitat3       -0.1403     0.2218  -0.633    0.527    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for Negative Binomial(0.4115) family taken to be 1)

    Null deviance: 230.15  on 254  degrees of freedom
Residual deviance: 219.83  on 252  degrees of freedom
AIC: 759.4

Number of Fisher Scoring iterations: 1


              Theta:  0.4115 
          Std. Err.:  0.0641 

 2 x log-likelihood:  -751.3990

这里的解释是什么?在我看来,habitat1 似乎是最受欢迎、最常用的栖息地类型??

现在我添加了与句号的交互;我也在周期上使用了总和对比,并在这里更改了基础,以获得“缺失”的交互。我将只显示两个输出,因为它与上面的栖息地原理相同。

nb_reg<-glm.nb(formula=counts~habitat*period+offset(log(obs)),data=speciescounts)
summary(nb_reg)

Call:
glm.nb(formula = counts ~ habitat * period + offset(log(obs)), 
    data = speciescounts, init.theta = 0.4672185898, link = log)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.4925  -1.0366  -0.7316   0.1038   4.6313  

Coefficients:
                      Estimate Std. Error z value Pr(>|z|)    
(Intercept)          -2.93450    0.19567 -14.997  < 2e-16 *** 
habitat1              0.64894    0.21399   3.033  0.00243 **   
habitat2             -0.36639    0.36510  -1.004  0.31560      
period1               0.09005    0.19567   0.460  0.64537      
habitat1:period1     -0.49599    0.21399  -2.318  0.02046 *   
habitat2:period1      0.07686    0.36510   0.211  0.83325     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for Negative Binomial(0.4672) family taken to be 1)

    Null deviance: 247.03  on 254  degrees of freedom
Residual deviance: 221.38  on 249  degrees of freedom
AIC: 751.73

Number of Fisher Scoring iterations: 1


              Theta:  0.4672 
          Std. Err.:  0.0756 

 2 x log-likelihood:  -737.7250

Call:
glm.nb(formula = counts ~ habitat * period + offset(log(obs)), 
    data = speciescounts, init.theta = 0.4672185898, link = log)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.4925  -1.0366  -0.7316   0.1038   4.6313  

Coefficients:
                  Estimate Std. Error z value Pr(>|z|)    
(Intercept)       -2.93450    0.19567 -14.997   <2e-16 ***
habitat2          -0.36639    0.36510  -1.004   0.3156    
habitat3          -0.28255    0.22502  -1.256   0.2092    
period1            0.09005    0.19567   0.460   0.6454    
habitat2:period1   0.07686    0.36510   0.211   0.8333    
habitat3:period1   0.41913    0.22502   1.863   0.0625
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for Negative Binomial(0.4672) family taken to be 1)

    Null deviance: 247.03  on 254  degrees of freedom
Residual deviance: 221.38  on 249  degrees of freedom
AIC: 751.73

Number of Fisher Scoring iterations: 1


              Theta:  0.4672 
          Std. Err.:  0.0756 

 2 x log-likelihood:  -737.7250

因此,habitat1 和 period1 之间存在显着的相互作用,但我再次不确定如何解释它。对我来说,在 period1 期间,栖息地 1 中的动物似乎更少,但与什么相比更少?

如果有人可以提供帮助,我会很高兴!谢谢!

【问题讨论】:

    标签: regression interaction contrast interpretation


    【解决方案1】:

    对于您的交互模型,您似乎已将第二个周期级别设置为参考级别(SAS 也是如此)。截距估计等于栖息地 1 的第二个周期。 时期的“主效应”是指时期基准水平的栖息地差异,这似乎是时期 2。
    顺便说一句,我会添加几个 cmets。不确定您的相互作用效果的强度”,我会考虑其他可能的参数化,例如比较栖息地内的时期。 ... 计数 ~ 栖息地/周期 -1 ,数据 = .... 或将计数视为两个时期的双变量响应。 另一个想法是将第一个计数设为协变量,然后将第二个计数作为响应进行分析。型号可能是 .... count2 ~ count1*栖息地,....

    【讨论】:

      猜你喜欢
      • 2019-03-19
      • 2018-10-06
      • 2014-07-27
      • 2018-12-03
      • 1970-01-01
      • 2022-09-09
      • 2017-06-14
      • 2021-09-20
      • 1970-01-01
      相关资源
      最近更新 更多