Poisson GLM 接受非整数的事实让我感到非常震惊!看:
数据(内容data.txt
):
1 2001 0.25 1
1 2002 0.5 1
1 2003 1 1
2 2001 0.25 1
2 2002 0.5 1
2 2003 1 1
R脚本:
t <- read.table("data.txt")
names(t) <- c('site', 'year', 'count', 'weight')
tm <- glm(count ~ 0 + as.factor(site) + as.factor(year), data = t,
family = "quasipoisson") # also works with family="poisson"
years <- 2001:2003
plot(years, exp(c(0, tail(coef(tm), length(years)-1))), type = "l")
结果年份指数与“预期”一样,即1-2-4
以年为单位2001-2003
。
但是泊松 GLM 怎么可能采用非整数呢?泊松分布一直都是整数!