泊松回归 AIC table
Poisson regression AIC table
我正在 R 中进行一系列泊松回归,然后根据 AIC 对我的模型进行排名。但是我得到的结果是:
> aictab(cand.set = Cand.models, sort = TRUE)
Model selection based on AICc :
K AICc Delta_AICc AICcWt Cum.Wt LL
Mod7 4 Inf NaN NaN NA -Inf
Mod6 3 Inf NaN NaN NA -Inf
Mod5 3 Inf NaN NaN NA -Inf
Mod4 3 Inf NaN NaN NA -Inf
Mod3 2 Inf NaN NaN NA -Inf
Mod2 2 Inf NaN NaN NA -Inf
Mod1 2 Inf NaN NaN NA -Inf
每个模型分别给出截距的结果,但不给出 AIC 的结果...
> Cand.models[[1]]
Call: glm(formula = D ~ A, family = poisson(), data = d)
Coefficients:
(Intercept) Slope
-0.17356 0.07058
Degrees of Freedom: 251 Total (i.e. Null); 250 Residual
Null Deviance: 55.35
Residual Deviance: 54.99 AIC: Inf
当我对 family=gaussian(identity) 做同样的事情时,我得到了结果。为什么我做泊松回归时 AIC 不工作?
如有任何帮助,我们将不胜感激。
很难理解为什么你在没有看到你的数据或代码的情况下得到你现在的结果(下次提示)。但是 AIC(c) 模型选择绝对可以与泊松回归一起使用——下面是一个例子:
library(AICcmodavg)
# make some dummy data (taken from: http://stats.stackexchange.com/questions/11096/how-to-interpret-coefficients-in-a-poisson-regression)
treatment <- factor(rep(c(1, 2), c(43, 41)),
levels = c(1, 2),
labels = c("placebo", "treated"))
improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)),
levels = c(1, 2, 3),
labels = c("none", "some", "marked"))
numberofdrugs <- rpois(84, 10) + 1
healthvalue <- rpois(84, 5)
y <- data.frame(healthvalue, numberofdrugs, treatment, improved)
# Model selection using AICc
# setup a list of candidate models
Cand.models <- list( )
Cand.models[[1]] <- glm(healthvalue~numberofdrugs+treatment+improved, data=y, family=poisson)
Cand.models[[2]] <- glm(healthvalue~treatment, data=y, family=poisson)
# create a vector of names to trace back models in set
Modnames <- paste("mod", 1:length(Cand.models), sep = " ")
# generate AICc table
aictab(cand.set = Cand.models, modnames = Modnames, sort = TRUE)
确保公式中的 D 由整数非 0 值组成,否则泊松 glm LL 会爆炸。
我正在 R 中进行一系列泊松回归,然后根据 AIC 对我的模型进行排名。但是我得到的结果是:
> aictab(cand.set = Cand.models, sort = TRUE)
Model selection based on AICc :
K AICc Delta_AICc AICcWt Cum.Wt LL
Mod7 4 Inf NaN NaN NA -Inf
Mod6 3 Inf NaN NaN NA -Inf
Mod5 3 Inf NaN NaN NA -Inf
Mod4 3 Inf NaN NaN NA -Inf
Mod3 2 Inf NaN NaN NA -Inf
Mod2 2 Inf NaN NaN NA -Inf
Mod1 2 Inf NaN NaN NA -Inf
每个模型分别给出截距的结果,但不给出 AIC 的结果...
> Cand.models[[1]]
Call: glm(formula = D ~ A, family = poisson(), data = d)
Coefficients:
(Intercept) Slope
-0.17356 0.07058
Degrees of Freedom: 251 Total (i.e. Null); 250 Residual
Null Deviance: 55.35
Residual Deviance: 54.99 AIC: Inf
当我对 family=gaussian(identity) 做同样的事情时,我得到了结果。为什么我做泊松回归时 AIC 不工作?
如有任何帮助,我们将不胜感激。
很难理解为什么你在没有看到你的数据或代码的情况下得到你现在的结果(下次提示)。但是 AIC(c) 模型选择绝对可以与泊松回归一起使用——下面是一个例子:
library(AICcmodavg)
# make some dummy data (taken from: http://stats.stackexchange.com/questions/11096/how-to-interpret-coefficients-in-a-poisson-regression)
treatment <- factor(rep(c(1, 2), c(43, 41)),
levels = c(1, 2),
labels = c("placebo", "treated"))
improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)),
levels = c(1, 2, 3),
labels = c("none", "some", "marked"))
numberofdrugs <- rpois(84, 10) + 1
healthvalue <- rpois(84, 5)
y <- data.frame(healthvalue, numberofdrugs, treatment, improved)
# Model selection using AICc
# setup a list of candidate models
Cand.models <- list( )
Cand.models[[1]] <- glm(healthvalue~numberofdrugs+treatment+improved, data=y, family=poisson)
Cand.models[[2]] <- glm(healthvalue~treatment, data=y, family=poisson)
# create a vector of names to trace back models in set
Modnames <- paste("mod", 1:length(Cand.models), sep = " ")
# generate AICc table
aictab(cand.set = Cand.models, modnames = Modnames, sort = TRUE)
确保公式中的 D 由整数非 0 值组成,否则泊松 glm LL 会爆炸。