coefCI
Confidence intervals of coefficient estimates of generalized linear regression model
Description
Examples
Find Confidence Intervals for Model Coefficients
Find the confidence intervals for the coefficients of a fitted generalized linear regression model.
Generate sample data using Poisson random numbers with two underlying predictors X(:,1)
and X(:,2)
.
rng('default') % For reproducibility rndvars = randn(100,2); X = [2 + rndvars(:,1),rndvars(:,2)]; mu = exp(1 + X*[1;2]); y = poissrnd(mu);
Create a generalized linear regression model of Poisson data.
mdl = fitglm(X,y,'y ~ x1 + x2','Distribution','poisson')
mdl = Generalized linear regression model: log(y) ~ 1 + x1 + x2 Distribution = Poisson Estimated Coefficients: Estimate SE tStat pValue ________ _________ ______ ______ (Intercept) 1.0405 0.022122 47.034 0 x1 0.9968 0.003362 296.49 0 x2 1.987 0.0063433 313.24 0 100 observations, 97 error degrees of freedom Dispersion: 1 Chi^2-statistic vs. constant model: 2.95e+05, p-value = 0
Find 95% (default) confidence intervals for the coefficients of the model.
ci = coefCI(mdl)
ci = 3×2
0.9966 1.0844
0.9901 1.0035
1.9744 1.9996
Find 99% confidence intervals for the coefficients.
alpha = 0.01; ci = coefCI(mdl,alpha)
ci = 3×2
0.9824 1.0986
0.9880 1.0056
1.9703 2.0036
Input Arguments
mdl
— Generalized linear regression model
GeneralizedLinearModel
object | CompactGeneralizedLinearModel
object
Generalized linear regression model, specified as a GeneralizedLinearModel
object created using fitglm
or stepwiseglm
, or a CompactGeneralizedLinearModel
object created using compact
.
alpha
— Significance level
0.05 (default) | numeric value in the range [0,1]
Significance level for the confidence interval, 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
interval does not contain the true value.
Example: 0.01
Data Types: single
| double
Output Arguments
ci
— Confidence intervals
numeric matrix
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
Confidence Interval
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
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)