Documentation

coefCI

班级:CompactLinearModel

线性模型系数估计的置信区间

Syntax

ci = coefCI(mdl)
CI = COEFCI(MDL,Alpha)

Description

ci= coefCI(MDL)returns confidence intervals for the coefficients inMDL

ci= coefCI(MDL,alpha)使用置信度返回置信区间1 -alpha

Input Arguments

expand all

Linear model object, specified as a full线性模型object constructed usingfitlm或者stepwiselm, or a compactedCompactLinearModelobject constructed usingcompact

Confidence interval, specified as a numeric value in the range [0,1].alpha是置信区间不包含真实值的概率。

Output Arguments

expand all

Confidence intervals, returned as ak-by-2 numeric matrix. Thejth row ofciis the confidence interval of coefficientjMDL。系数的名称j存储在MDLpropertyCoefficientNames

Examples

expand all

根据基于自动里程的线性回归模型carbigdata. Then obtain the default 95% confidence intervals for the resulting model coefficients.

Load the data and create a table.

loadcarbigOrigin = nominal(Origin); tbl = table(Horsepower,Weight,MPG,Origin);

Fit a linear regression model. Use horsepower, weight, and origin as predictor variables, and miles per gallon as the response variable.

modelspec ='mpg〜1 +马力 +重量 +起源'; mdl = fitlm(tbl,modelspec);

View the names of the coefficients.

MDL。CoefficientNames
ans = 1×9 cell array Columns 1 through 4 '(Intercept)' 'Horsepower' 'Weight' 'Origin_France' Columns 5 through 8 'Origin_Germany' 'Origin_Italy' 'Origin_Japan' 'Origin_Sweden' Column 9 'Origin_USA'

Find confidence intervals for the coefficients of the model.

ci = coefCI(mdl)
ci = 43.3611 59.9390 -0.0748 -0.0315 -0.0059 -0.0037 -17.3623 -0.3477 -15.7503 0.7434 -17.2091 0.0613 -14.5106 1.8738 -18.5820 -1.5036 -17.3114 -0.9642

根据基于自动里程的线性回归模型carbigdata. Then obtain confidence intervals for the resulting model coefficients at the 99% level.

Load the data and create a table.

loadcarbigOrigin = nominal(Origin); tbl = table(Horsepower,Weight,MPG,Origin);

Fit a linear regression model using horsepower, weight, and origin as the predictor variables, and miles per gallon as the response variable.

modelspec ='mpg〜1 +马力 +重量 +起源'; mdl = fitlm(tbl,modelspec);

找到该系数的99%置信区间。

ci = coefCI(mdl,.01)
ci = 40.7365 62.5635 -0.0816 -0.0246 -0.0062 -0.0034 -20.0560 2.3459 -18.3615 3.3546 -19.9433 2.7955 -17.1045 4.4676 -21.2858 1.2002 -19.8995 1.6238

置信区间比默认的5%置信区间宽。

Definitions

expand all

Alternatives

You can create the intervals from the model coefficients inMDL。Coefficients.Estimateand an appropriate multiplier of the standard errorssqrt(diag(MDL。The multiplier istinv(1-alpha/2,dof), where等级is the confidence level, anddofis the degrees of freedom (number of data points minus the number of coefficients).

这个话题有帮助吗?