Main Content

coefci

Confidence interval for Cox proportional hazards model coefficients

Since R2021a

    Description

    example

    ci = coefci(coxMdl) returns a 95% confidence interval for the coefficients of a trained Cox proportional hazards model.

    example

    ci = coefci(coxMdl,level) returns a 100(1 – level)% confidence interval for the coefficients.

    Examples

    collapse all

    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 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

    collapse all

    Fitted Cox proportional hazards model, specified as a CoxModel object. Create coxMdl using fitcox.

    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

    collapse all

    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