计算泊松回归系数的置信区间 [英] calculating confidence interval of coefficient in poisson regression
问题描述
泊松回归在我的 R 代码中如下所示:
The poisson regression looks as follows in My R-code:
poissmod <- glm(aerobics$y ~ factor(aerobics$x1) + factor(aerobics$x2) + aerobics$x3 + aerobics$x4, family = poisson)
poissmod
现在我必须计算因子 aerobics$x1
的置信区间(在没有 aerobics$x1
的模型中,因为这并不重要).
Now I have to compute a confidence interval for the factor aerobics$x1
(in a model without aerobics$x1
since this is not significant).
这可能看起来很简单,但我对 R 不熟悉,而且我在任何地方都找不到答案...
This might look very easy, but I am not familiar with R and I can 't find the answer anywhere...
谁能帮帮我?
非常感谢!
推荐答案
参见例如MASS
包中的 confint
函数 (http://stat.ethz.ch/R-manual/R-devel/library/MASS/html/confint.html):
See e.g. the confint
function in the MASS
package (http://stat.ethz.ch/R-manual/R-devel/library/MASS/html/confint.html):
ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive = 20 - numdead)
budworm.lg0 <- glm(SF ~ sex + ldose - 1, family = binomial)
confint(budworm.lg0)
confint(budworm.lg0, "ldose")
该示例适用于逻辑回归,但这也适用于泊松回归.
The example is for a logistic regression, but this will also work for a poisson regression.
这是 stats
包文档中关于泊松回归的另一个示例 (https://stat.ethz.ch/R-manual/R-devel/library/stats/html/confint.html):
Here is another example from the stats
package documentation for a poisson regression (https://stat.ethz.ch/R-manual/R-devel/library/stats/html/confint.html):
## from example(glm)
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3, 1, 9); treatment <- gl(3, 3)
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
confint(glm.D93) # needs MASS to be present on the system
confint.default(glm.D93) # based on asymptotic normality
这篇关于计算泊松回归系数的置信区间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!