在R,擬合GLM後你可以得到含殘餘偏差和零偏差,它告訴你你的模型是如何好相比只有截距項的模型,對於例如模型摘要信息:如何在Matlab fitglm中獲得R的零值和殘差等值?
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