coefci
Description
Examples
Cox Model Confidence Interval
Perform a Cox proportional hazards regression on the lightbulb
data set, which contains simulated lifetimes of light bulbs. The first column of the light bulb data contains the lifetime (in hours) of two different types of bulbs. The second column contains a binary variable indicating whether the bulb is fluorescent or incandescent; 0 indicates the bulb is fluorescent, and 1 indicates it is incandescent. The third column contains the censoring information, where 0 indicates the bulb was observed until failure, and 1 indicates the observation was censored.
Fit a Cox proportional hazards model for the lifetime of the light bulbs, accounting for censoring. The predictor variable is the type of bulb.
load lightbulb coxMdl = fitcox(lightbulb(:,2),lightbulb(:,1), ... 'Censoring',lightbulb(:,3))
coxMdl = Cox Proportional Hazards regression model Beta SE zStat pValue ______ ______ ______ __________ X1 4.7262 1.0372 4.5568 5.1936e-06 Log-likelihood: -212.638
Find a 95% confidence interval for the returned Beta
estimate.
ci = coefci(coxMdl)
ci = 1×2
2.6934 6.7590
Find a 99% confidence interval for the Beta
estimate.
ci99 = coefci(coxMdl,0.01)
ci99 = 1×2
2.0546 7.3978
Confidence Intervals for Multiple Predictors
Find confidence intervals for predictors of the readmissiontimes
data set. The response variable is ReadmissionTime
, which shows the readmission times for 100 patients. The predictor variables are Age
, Sex
, Weight
, and Smoker
, the smoking status of each patient. A 1 indicates the patient is a smoker, and a 0 indicates the patient does not smoke. The column vector Censored
contains the censorship information for each patient, where 1 indicates censored data, and 0 indicates the exact readmission times are observed. (This data is simulated.)
Load the data.
load readmissiontimes
Use all four predictors for fitting a model.
X = [Age Sex Weight Smoker];
Fit the model using the censoring information.
coxMdl = fitcox(X,ReadmissionTime,'censoring',Censored);
View the point estimates for the Age
, Sex
, Weight
, and Smoker
coefficients.
coxMdl.Coefficients.Beta
ans = 4×1
0.0184
-0.0676
0.0343
0.8172
Find 95% confidence intervals for these estimates.
ci = coefci(coxMdl)
ci = 4×2
-0.0139 0.0506
-1.6488 1.5136
0.0042 0.0644
0.2767 1.3576
The Sex
coefficient (second row) has a large confidence interval, and the first two coefficients bracket the value 0. Therefore, you cannot reject the hypothesis that the Age
and Sex
predictors are zero.
Input Arguments
level
— Level of significance for confidence interval
0.05
(default) | positive number less than 1
Level of significance for the confidence interval, specified as a positive number
less than 1
. The resulting percentage is 100(1 –
level
)%. For example, for a 99% confidence interval, specify
level
as 0.01
.
Example: 0.01
Data Types: double
Output Arguments
ci
— Confidence interval
real two-column matrix
Confidence interval, returned as a real two-column matrix. Each row of the matrix is
a confidence interval for the corresponding predictor. The probability that the true
predictor coefficient lies in its confidence interval is 100(1 –
level
)%. For example, the default value of level
is 0.05
, so with no level
specified, the
probability that each predictor lies in its row of ci
is 95%.
Version History
Introduced in R2021a
See Also
CoxModel
| linhyptest
| fitcox
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)