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/

相关文章:

c++ - RcppEigen 稀疏矩阵插入操作给出无效类 “dgCMatrix” 错误

r - 将 ggplot2 与 R : Looks and Syntax 中的基本图相结合

R用组内另一个列值的下一个值替换NA值

r - 基于 'count' 变量整理数据 : create row for each individual,

r - 为 glm 使用 modelr::add_predictions

R: 在 glm() 和 bestglm() 中找不到函数 "function (object, ...)\nobject"

R 中速率变量的回归

machine-learning - 返回置信度的分类算法?

r - 向对数回归添加置信区间

python - ARMA.predict 的预测区间