coefCI
Confidence intervals of coefficient estimates of linear regression model
Description
Examples
Fit a linear regression model and obtain the default 95% confidence intervals for the resulting model coefficients.
Load the carbig data set and create a table in which the Origin predictor is categorical.
load carbig
Origin = categorical(cellstr(Origin));
tbl = table(Horsepower,Weight,MPG,Origin);Fit a linear regression model. Specify Horsepower, Weight, and Origin as predictor variables, and specify MPG as the response variable.
modelspec = 'MPG ~ 1 + Horsepower + Weight + Origin';
mdl = fitlm(tbl,modelspec);View the names of the coefficients.
mdl.CoefficientNames
ans = 1×9 cell
{'(Intercept)'} {'Horsepower'} {'Weight'} {'Origin_France'} {'Origin_Germany'} {'Origin_Italy'} {'Origin_Japan'} {'Origin_Sweden'} {'Origin_USA'}
Find confidence intervals for the coefficients of the model.
ci = coefCI(mdl)
ci = 9×2
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
Fit a linear regression model and obtain the confidence intervals for the resulting model coefficients using a specified confidence level.
Load the carbig data set and create a table in which the Origin predictor is categorical.
load carbig
Origin = categorical(cellstr(Origin));
tbl = table(Horsepower,Weight,MPG,Origin);Fit a linear regression model. Specify Horsepower, Weight, and Origin as predictor variables, and specify MPG as the response variable.
modelspec = 'MPG ~ 1 + Horsepower + Weight + Origin';
mdl = fitlm(tbl,modelspec);Find 99% confidence intervals for the coefficients.
ci = coefCI(mdl,.01)
ci = 9×2
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
The confidence intervals are wider than the default 95% confidence intervals in Find Confidence Intervals for Model Coefficients.
Input Arguments
Linear regression model object, specified as a LinearModel object created by using fitlm or stepwiselm, or a CompactLinearModel object created by using compact.
Significance level for the confidence interval,s specified as a numeric value in the
range [0,1]. The confidence level of ci is equal to 100(1 – alpha)%. alpha is the probability that the confidence
intervals do not contain the true value.
Example: 0.01
Data Types: single | double
Output Arguments
Confidence intervals, returned as a k-by-2 numeric matrix, where
k is the number of coefficients. The jth row
of ci is the confidence interval of the jth
coefficient of mdl. The name of coefficient j is
stored in the CoefficientNames property of
mdl.
Data Types: single | double
More About
The coefficient confidence intervals provide a measure of precision for regression coefficient estimates.
A 100(1 – α)% confidence interval gives the range for the corresponding regression coefficient with 100(1 – α)% confidence, meaning that 100(1 – α)% of the intervals resulting from repeated experimentation will contain the true value of the coefficient.
The software finds confidence intervals using the Wald method. The 100(1 – α)% confidence intervals for regression coefficients are
where bi is the coefficient estimate, SE(bi) is the standard error of the coefficient estimate, and t(1–α/2,n–p) is the 100(1 – α/2) percentile of the t-distribution with n – p degrees of freedom. n is the number of observations and p is the number of regression coefficients.
Extended Capabilities
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2012a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)