【发布时间】:2016-11-20 15:33:30
【问题描述】:
在 R 中,拟合 glm 后,您可以获得包含剩余偏差和空偏差的摘要信息,这些信息告诉您您的模型与仅使用截距项的模型相比有多好,例如模型:
model <- glm(formula = am ~ mpg + qsec, data=mtcars, family=binomial)
我们有:
> summary(model)
...
Null deviance: 43.2297 on 31 degrees of freedom
Residual deviance: 7.5043 on 29 degrees of freedom
AIC: 13.504
...
在 Matlab 中,当您使用 fitglm 时,您会返回 GeneralizedLinearModel 类的对象,该对象具有包含剩余偏差的 Deviance 属性。但是,我找不到与空偏差直接相关的任何内容。最简单的计算方法是什么?
示例 Matlab 代码:
load fisheriris.mat
model = fitglm(meas(:, 1), ismember(species, {'setosa'}), 'Distribution', 'binomial')
产生:
model =
Generalized Linear regression model:
logit(y) ~ 1 + x1
Distribution = Binomial
Estimated Coefficients:
Estimate SE tStat pValue
_________________ _________________ _________________ ____________________
(Intercept) 27.8285213954246 4.8275686220899 5.76450042948896 8.19000695766331e-09
x1 -5.17569812610148 0.893399843474784 -5.79326061438645 6.90328570107794e-09
150 observations, 148 error degrees of freedom
Dispersion: 1
Chi^2-statistic vs. constant model: 119, p-value = 9.87e-28
剩余偏差为model.Deviance:
>> model.Deviance
ans =
71.8363992272217
【问题讨论】: