我想尝试预测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