M.ain Content

DevianceTest.

Analysis of deviance for generalized linear regression model

描述

例子

tbl= deviancetest(mdl的)返回广义线性回归模型的偏差表分析mdl。T.he tabletblgives the result of a test that determines whether the modelmdl非常符合恒定模型的更好。

例子

全部收缩

Perform a deviance test on a generalized linear regression model.

使用具有两个底层预测器的泊松随机数生成样本数据X(:,1)andX(:,2)

rng('default'的)% For reproducibilityrndvars = randn(100,2); X = [2 + rndvars(:,1),rndvars(:,2)]; mu = exp(1 + X*[1;2]); y = poissrnd(mu);

创建泊松数据的广义线性回归模型。

mdl = fitglm(x,y,'y〜x1 + x2''分配''泊松'的)
MDL =广义线性回归模型:日志(y)的〜1 + X1 + X2分布=泊松估计系数:估计SE TSTAT p值________ _________ ______(截距)1.0405 0.022122 47.034 0 X1 0.9968 0.003362 296.49 0×2 1.987 0.0063433 313.24 0 100观察,97个误差自由度分散:1 chi ^ 2统计与常数型号:2.95e + 05,p值= 0

T.est whether the model differs from a constant in a statistically significant way.

tbl = devianceTest(mdl)
TBL =2×4表偏差dfe chi2stat pvalue _____________ __________ ______ log(y)〜1 2.9544e + 05 99 log(y)〜1 + x1 + x2 107.4 97 2.9533E + 05 0

T.he smallP.-Value表示该模型与常数显着不同。请注意,模型显示mdl包括表中显示的第二行中显示的统计信息。

输入参数

全部收缩

广义线性回归模型那S.P.ecified as aGeneralizedLinearModel.使用的对象使用Fitglm.or挺身油那or aCompactGeneralizedLinearModel使用的对象使用compact

输出参数

全部收缩

分析偏差摘要统计数据,作为表返回。

tbl包含恒定模型和模型的偏差统计分析mdl。该表包含每个模型的这些列。

Column 描述
D.eviance

偏差是相应模型的loglikelience之间的两倍(mdl或常数)和饱和模型。有关更多信息,请参阅D.eviance

DFE.

错误的自由度(残差),等于N.-P., 在哪里N.是观察数,和P.是the number of estimated coefficients

Chi2stat.

F统计或卡方统计,根据whether the dispersion is estimated (F-statistic) or not (chi-squared statistic)

  • F-statistic is the difference between the deviance of the constant model and the deviance of the full model, divided by the estimated dispersion.

  • Chi-Squared统计是恒定模型的偏差与完整模型的偏差之间的差异。

pvalue.

P.-value associated with the test: chi-squared statistic withP.- 1自由度,或F- 史密斯P.- 1N.umerator degrees of freedom andDFE.分母自由度,在哪里P.是the number of estimated coefficients

更多关于

全部收缩

D.eviance

D.eviance is a generalization of the residual sum of squares. It measures the goodness of fit compared to a saturated model.

模范的偏差M.1模型的Loglikelihie之间是两倍的差异M.1和饱和的模型M.S.。饱和模型是一种模型,具有最大参数数量的模型。

For example, if you haveN.观察(y一世一世=1那2那。。。那N.)具有潜在不同的价值X一世T.β,然后您可以定义饱和模型N.P.arameters. LetL.B.y)表示具有参数的模型的似然函数的最大值B.。T.hen the deviance of the modelM.1

- 2 log L. B. 1 y 的) - log L. B. S. y 的) 的)

在哪里B.1andB.S.contain the estimated parameters for the modelM.1和饱和的模型那respectively. The deviance has a chi-square distribution withN.-P.degrees of freedom, whereN.是饱和模型中的参数数量和P.是the number of parameters in the modelM.1

假设您有两个不同的广义线性回归模型M.1andM.2那andM.1has a subset of the terms inM.2。You can assess the fit of the models by comparing the deviancesD.1andD.2两种模型。偏离的差异是

D. = D. 2 - D. 1 = - 2 log L. B. 2 y 的) - log L. B. S. y 的) 的) + 2 log L. B. 1 y 的) - log L. B. S. y 的) 的) = - 2 log L. B. 2 y 的) - log L. B. 1 y 的) 的)

Asymptotically, the differenceD.has a chi-square distribution with degrees of freedomV.equal to the difference in the number of parameters estimated inM.1andM.2。You can obtain theP.- 通过使用来进行此测试1 - CHI2CDF(D,V)

T.yP.一世cally, you examineD.使用模型M.2持续期限,没有预测因子。所以,D.has a chi-square distribution withP.- 1degrees of freedom. If the dispersion is estimated, the difference divided by the estimated dispersion has anF分销P.- 1N.umerator degrees of freedom andN.-P.分母自由度。

扩展能力

Introduced in R2012a