小编ver*_*ion的帖子

检查残差并可视化零膨胀泊松 r

我正在为 CPUE 数据运行零膨胀模型。该数据有零通货膨胀的证据,我已通过 Vuong 测试(在下面的代码中)确认了这一点。根据 AIC 的说法,完整模型 (zint) 优于零模型。我现在想要:

  1. 检查完整模型的残差以确定模型拟合(由于缺乏来自同事、互联网和 R 书籍的信息而遇到麻烦)
  2. 如果模型拟合看起来不错,则可视化模型的输出(使用偏移变量时如何制定实际参数值的方程)

我向该部门的几位统计学家寻求帮助(他们以前从未这样做过,并将我发送到相同的谷歌搜索网站),向统计部门本身(每个人都太忙)以及 stackoverflow feed 寻求帮助。

我很欣赏书籍的代码或指南(在线免费提供),其中包含使用偏移变量时处理可视化 ZIP 和模型拟合的代码。

 yc=read.csv("CPUE_ycs_trawl_withcobb_BLS.csv",header=TRUE)
 yc=yc[which(yc$countinyear<150),]
 yc$fyear=as.factor(yc$year_cap)
 yc$flocation=as.factor(yc$location)
 hist(yc$countinyear,20)
 yc$logoffset=log(yc$numtrawlyr)

 ###Run Zero-inflated poisson with offset for CPUE####
 null <- formula(yc$countinyear ~ 1| 1)
 znull <- zeroinfl(null, offset=logoffset,dist = "poisson",link = "logit",
 data = yc)

 int <- formula(yc$countinyear ~ assnage * spawncob| assnage * spawncob)
 zint <- zeroinfl(int, offset=logoffset,dist = "poisson",link = "logit", data  
 = yc)
 AIC(znull,zint)

  g1=glm(countinyear ~ assnage * spawncob,
  offset=logoffset,data=yc,family=poisson)
  summary(g1)

 ####Vuong …
Run Code Online (Sandbox Code Playgroud)

r poisson

7
推荐指数
1
解决办法
5058
查看次数

使用交互项引导 lmer

lme4我正在R 中使用混合模型:

full_mod3=lmer(logcptplus1 ~ logdepth*logcobb + (1|fyear) + (1 |flocation),
data=cpt, REML=TRUE)
Run Code Online (Sandbox Code Playgroud)

概括:

Formula: logcptplus1 ~ logdepth * logcobb + (1 | fyear) + (1 | flocation)
   Data: cpt

REML criterion at convergence: 577.5

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.7797 -0.5431  0.0248  0.6562  2.1733 

 Random effects:
 Groups    Name        Variance Std.Dev.
 fyear     (Intercept) 0.2254   0.4748  
 flocation (Intercept) 0.1557   0.3946  
 Residual              0.9663   0.9830  
Number of obs: 193, groups:  fyear, 16; flocation, 16

Fixed effects:
                  Estimate Std. Error t value …
Run Code Online (Sandbox Code Playgroud)

r lme4 statistics-bootstrap

4
推荐指数
1
解决办法
1875
查看次数

标签 统计

r ×2

lme4 ×1

poisson ×1

statistics-bootstrap ×1