【发布时间】:2021-11-03 17:11:35
【问题描述】:
我正在尝试对计数数据集进行 GLM,但发现我的数据过于分散,因此不适合使用泊松 GLM。我知道我必须改用负二项式 GLM,这需要一个 theta 值。但是,当我尝试运行我的模型的摘要时,我会在下面收到一系列错误,并且找不到 theta 值。对此的任何帮助将不胜感激。我将总结我的数据集和用于生成模型摘要的代码以及下面的错误。
数据集摘要:
用于 GLM 的数据是总数(计数数据)和治疗(代表不同治疗的字母,例如 C、M、F)
用于产生 theta 的代码:
summary(m1 <- glm.nb(Total ~ Treatment, data = twohour))
此代码的输出,底部有错误:
我们将不胜感激任何有关产生 theta 值的帮助。提前致谢。
根据要求,摘要和模型输出为文本:
总结:
> summary(twohour)
Treatment | Length | ID | Block1 Block2 | Fertility | Notes | Total
Length:252 | Length:252 | Min. : 1.00 | Min. : 0.0 Min. : 0.00 Min. :0.0000 Length:252 Min. : 0.0
Class :character Class :character 1st Qu.:10.00 1st Qu.:125.8 1st Qu.: 39.50 1st Qu.:1.0000 Class :character 1st Qu.:172.2
Mode :character Mode :character Median :19.50 Median :154.0 Median :104.50 Median :1.0000 Mode :character Median :263.0
Mean :19.89 Mean :143.5 Mean : 94.66 Mean :0.9683 Mean :238.1
3rd Qu.:30.00 3rd Qu.:179.2 3rd Qu.:146.00 3rd Qu.:1.0000 3rd Qu.:309.5
Max. :40.00 Max. :227.0 Max. :228.00 Max. :1.0000 Max. :434.0
模型输出:
> Call: glm.nb(formula = Total ~ Treatment, data = twohour, init.theta =
> 2055605.705,
> link = log)
>
> Deviance Residuals:
> Min 1Q Median 3Q Max
> -23.001 -4.624 1.650 4.567 12.571
>
> Coefficients:
Estimate Std. Error z value Pr(>|z|) (Intercept) 5.577987 0.009846 566.534 < 2e-16 *** TreatmentC -0.102625 0.014394 -7.130 1.01e-12 *** TreatmentF -0.154580 0.014396 -10.737 < 2e-16 *** TreatmentF30 -0.298972 0.019920 -15.008 < 2e-16 *** TreatmentM -0.158733 0.014613 -10.862 < 2e-16 ***
TreatmentM30 -0.044795 0.013992 -3.201 0.00137 ** TreatmentMxF
-0.105191 0.014211 -7.402 1.34e-13 ***
--- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for Negative Binomial(2055606) family taken to
be 1)
Null deviance: 15127 on 251 degrees of freedom Residual deviance: 14799 on 245 degrees of freedom AIC: 16542
Number of Fisher Scoring iterations: 1
Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width,
3L, : invalid 'nsmall' argument In addition: Warning messages:
1: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =control$trace : iteration limit reached
2: In sqrt(1/i) : NaNs produced
3: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace = control$trace > : iteration limit reached
4: In sqrt(1/i) : NaNs produced
【问题讨论】:
-
您能否将您的
summary()输出和模型输出发布为文本 而不是屏幕截图?使用屏幕阅读器的人无法搜索和访问屏幕截图... -
我已经这样做了,如果这有帮助,请告诉我。
-
嗯。有没有办法可以剪切和粘贴而保留格式(制表符或空格)?
-
我已经完成了,希望对您有所帮助。