coefci
Description
Examples
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
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 readmissiontimesUse 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 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
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.
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)