r - 如何从 glm R 中的泊松分布中提取置信区间?

标签 r glm confidence-interval poisson

我想尝试预测 glm poisson() 分布的置信区间。我尝试使用预测函数来提取上限和下限..但它似乎不起作用。关于我可以更改的内容有什么建议吗?

temp <- rnorm(100,20,2)
plant <- rnorm(100,5,1.5)
df <- data.frame(temp, plant)
mod <- glm(plant~temp + I(temp^2), df, family = poisson)
predicted.plant <- predict(mod, type = "response")
predict(predicted.plant, interval="confidence", level=.95)

最佳答案

investr::predFit 开箱即用。

library(investr)    
predFit(mod, interval='confidence', level=.95)

         fit       lwr      upr
1   1.385749 0.8536210 1.917877
2   1.595374 1.4652265 1.725522
3   1.578423 1.4590180 1.697828
4   1.616518 1.5044858 1.728551
5   1.607251 1.4874250 1.727076
6   1.614135 1.4987750 1.729494
7   1.613123 1.5045601 1.721687
8   1.608245 1.4891049 1.727384
9   1.608494 1.5017123 1.715275
10  1.605561 1.4845113 1.726612

关于r - 如何从 glm R 中的泊松分布中提取置信区间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71839344/

相关文章:

仅使用模型对象重现二项式 glm

r - R 包 lme4 中的 glmer 要求缩放变量,即使变量已经缩放

python - 双曲 Curve_Fit 的预测区间 - SciPy

r - 如何从 R 的 coxph 中获得 95% CI?

regex - 基于正则表达式创建新变量

ggplot2中离散y轴的倒序

r - 无法使用 rgp 执行任何符号回归

r - 将字体大小调整为绘图设备的大小

r - 贝叶斯预测,下标越界

r - ggplot2:带有平均值/95% 置信区间线的密度图