【发布时间】:2018-09-09 21:04:50
【问题描述】:
背景:我有以下数据运行glm 函数:
location = c("DH", "Bos", "Beth")
count = c(166, 57, 38)
#make into df
df = data.frame(location, count)
#poisson
summary(glm(count ~ location, family=poisson))
输出:
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.6376 0.1622 22.424 < 2e-16 ***
locationBos 0.4055 0.2094 1.936 0.0529 .
locationDH 1.4744 0.1798 8.199 2.43e-16 ***
问题:我想更改(Intercept),这样我就可以获得与Bos相关的所有值
我看了Change reference group using glm with binomial family 和How to force R to use a specified factor level as reference in a regression?。我尝试了那里的方法,但它不起作用,我不知道为什么。
试过了:
df1 <- within(df, location <- relevel(location, ref = 1))
#poisson
summary(glm(count ~ location, family=poisson, data = df1))
所需的输出:
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) ...
locationBeth ...
locationDH ...
问题:我该如何解决这个问题?
【问题讨论】:
标签: r output regression intercept coefficients