Main Content

coefCI

Confidence intervals of coefficient estimates for censored linear regression model

Since R2025a

    Description

    ci = coefCI(mdl) returns 95% confidence intervals for the coefficients in mdl.

    example

    ci = coefCI(mdl,alpha) returns confidence intervals using the confidence level 1 – alpha.

    example

    Examples

    collapse all

    Load the readmissiontimes sample data.

    load readmissiontimes

    The variables Age, Weight, Smoker, and ReadmissionTime contain data for patient age, weight, smoking status, and time of readmission. The Censored variable contains censoring information for ReadmissionTime.

    Save Age, Weight, Smoker, and ReadmissionTime in a table, and fit a censored linear regression model to the data.

    tbl = table(Age,Weight,Smoker,ReadmissionTime);
    mdl = fitlmcens(tbl,Censoring=Censored);

    View the names of the coefficients.

    mdl.CoefficientNames
    ans = 1×4 cell
        {'(Intercept)'}    {'Age'}    {'Weight'}    {'Smoker'}
    
    

    Calculate the confidence intervals for the model coefficients.

    ci = coefCI(mdl)
    ci = 4×2
    
       20.9887   34.4918
       -0.1716    0.0647
       -0.1444   -0.0776
       -4.1938   -0.4971
    
    

    Load the readmissiontimes sample data.

    load readmissiontimes

    The variables Age, Weight, Smoker, and ReadmissionTime contain data for patient age, weight, smoking status, and time of readmission. The Censored variable contains censoring information for ReadmissionTime.

    Save Age, Weight, Smoker, and ReadmissionTime in a table, and fit a censored linear regression model to the data.

    tbl = table(Age,Weight,Smoker,ReadmissionTime);
    mdl = fitlmcens(tbl,Censoring=Censored);

    Find the 99% confidence intervals for the coefficients.

    ci = coefCI(mdl,.01)
    ci = 4×2
    
       18.8009   36.6796
       -0.2099    0.1030
       -0.1552   -0.0668
       -4.7928    0.1019
    
    

    The confidence intervals are wider than the default 95% confidence intervals in the example Find Confidence Intervals for Model Coefficients.

    Input Arguments

    collapse all

    Censored linear regression model, specified as a CensoredLinearModel object created using fitlmcens, or a CompactCensoredLinearModel object created using fitlmcens and 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

    collapse all

    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

    collapse all

    Version History

    Introduced in R2025a