Main Content

CompactCensoredLinearModel

Compact censored linear regression model

Since R2025a

    Description

    CompactCensoredLinearModel is a compact version of a full, censored linear regression model object CensoredLinearModel. Because a compact model does not store the input data used to fit the model or information related to the fitting process, a CompactCensoredLinearModel object uses less memory than a CensoredLinearModel object. You can still use a compact model to predict responses using new input data, but some CensoredLinearModel object functions do not work with a compact model.

    Creation

    Create a CompactCensoredLinearModel model from a full, trained CensoredLinearModel object by using compact.

    Properties

    expand all

    Coefficient Estimates

    This property is read-only.

    Covariance matrix of coefficient estimates, represented as a p-by-p matrix of numeric values. p is the number of coefficients in the fitted model, as given by NumCoefficients.

    For details, see Coefficient Standard Errors and Confidence Intervals.

    Data Types: single | double

    This property is read-only.

    Coefficient names, represented as a cell array of character vectors, each containing the name of the corresponding term.

    Data Types: cell

    This property is read-only.

    Coefficient values, represented as a table that contains one row for each coefficient and these columns:

    • Estimate — Estimated coefficient value

    • SE — Standard error of the estimate

    • tStatt-statistic for a two-sided test with the null hypothesis that the coefficient is zero

    • pValuep-value for the t-statistic

    Use coefCI to find the confidence intervals of the coefficient estimates.

    To obtain any of these columns as a vector, index into the property using dot notation. For example, obtain the estimated coefficient vector in the model compactMdl:

    beta = compactMdl.Coefficients.Estimate

    Data Types: table

    This property is read-only.

    Number of model coefficients, represented as a positive integer. NumCoefficients includes coefficients that are set to zero when the model terms are rank deficient.

    Data Types: double

    Summary Statistics

    This property is read-only.

    Degrees of freedom for the error (residuals), equal to the number of observations minus the number of estimated coefficients, represented as a positive integer.

    Data Types: double

    This property is read-only.

    Loglikelihood of the response values, represented as a numeric scalar. The loglikelihood is based on the assumption that each response value follows a normal distribution. The mean of the normal distribution is the fitted (predicted) response value, and the estimated variance is mdl.Sigma2.

    Data Types: single | double

    This property is read-only.

    Criterion for model comparison, represented as a structure with these fields:

    • AIC — Akaike information criterion. AIC = –2*logL + 2*m, where logL is the loglikelihood and m is the number of estimated parameters.

    • AICc — Akaike information criterion corrected for the sample size. AICc = AIC + (2*m*(m + 1))/(n – m – 1), where n is the number of observations.

    • BIC — Bayesian information criterion. BIC = –2*logL + m*log(n).

    • CAIC — Consistent Akaike information criterion. CAIC = –2*logL + m*(log(n) + 1).

    Information criteria are model selection tools that you can use to compare multiple models fit to the same data. These criteria are likelihood-based measures of model fit that include a penalty for complexity (specifically, the number of parameters). Different information criteria are distinguished by the form of the penalty.

    When you compare multiple models, the model with the lowest information criterion value is the best-fitting model. The best-fitting model can vary depending on the criterion used for model comparison.

    To obtain any of the criterion values as a scalar, index into the property using dot notation. For example, obtain the AIC value aic in the model compactMdl:

    aic = compactMdl.ModelCriterion.AIC

    Data Types: struct

    This property is read-only.

    Chi-square statistic of the linear regression model vs. the constant model, represented as a structure. The constant model is a linear regression model that includes an intercept only.

    The ModelFitVsConstantModel structure contains these fields:

    • Chi2Stat — Chi-square statistic of the fitted model versus the constant model.

    • Pvalp-value for the chi-square statistic.

    • LogLConstant — Loglikelihood for the constant model. This statistic is used to calculate the loglikelihood vs. constant model statistic in the model display.

    Data Types: struct

    This property is read-only.

    Pseudo R-squared values for the fitted model, represented as a structure. Each field of Rsquared contains a pseudo R-squared value calculated with a different formula [1].

    FieldDescription
    'McFadden'

    The McFadden value is

    R2=1ln(LFull)ln(LNull),

    where LFull is the loglikelihood of the fitted model, and LNull is the loglikelihood of a model with no predictors.

    'AdjustedMcFadden'

    The adjusted McFadden value is

    R2=1ln(LFull)Kln(LNull),

    where K is the number of model coefficients in LFull.

    Data Types: struct

    This property is read-only.

    Estimate for the error standard deviation, represented as a numeric scalar.

    Data Types: single | double

    Input Data

    This property is read-only after object creation.

    Model information, represented as a LinearFormula object.

    Display the formula of the fitted model compactMdl using dot notation:

    compactMdl.Formula

    This property is read-only after object creation.

    Number of observations used to fit the model, represented as a positive integer. NumObservations is the number of observations supplied in the original table or matrix, minus any excluded rows or rows with missing values. To exclude rows, set with the ExcludeObservations name-value argument when you create the object with fitlmcens. The resulting model object mdl is the input to thecompact function.

    Data Types: double

    This property is read-only after object creation.

    Number of predictor variables used to fit the model, represented as a positive integer.

    Data Types: double

    This property is read-only after object creation.

    Number of right-censored observations, represented as a positive integer.

    Data Types: double

    This property is read-only after object creation.

    Number of left-censored observations, represented as a positive integer.

    Data Types: double

    This property is read-only after object creation.

    Number of interval-censored observations, represented as a positive integer.

    Data Types: double

    This property is read-only after object creation.

    Number of uncensored observations, represented as a positive integer.

    Data Types: double

    This property is read-only after object creation.

    Number of variables in the input data, represented as a positive integer. NumVariables is the number of variables in the original table, or the total number of columns in the predictor matrix and response vector.

    NumVariables also includes any variables not used to fit the model as predictors or as the response.

    Data Types: double

    This property is read-only after object creation.

    Names of predictors used to fit the model, represented as a cell array of character vectors.

    Data Types: cell

    This property is read-only after object creation.

    Response variable name, represented as a character vector.

    Data Types: char

    This property is read-only after object creation.

    Information about the variables contained in Variables, represented as a table with one row for each variable and the columns described below.

    ColumnDescription
    ClassVariable class, specified as a cell array of character vectors, such as 'double' and 'categorical'
    Range

    Variable range, specified as a cell array of vectors

    • Continuous variable — Two-element vector [min,max], the minimum and maximum values

    • Categorical variable — Vector of distinct variable values

    InModelIndicator of which variables are in the fitted model, specified as a logical vector. The value is true if the model includes the variable.
    IsCategoricalIndicator of categorical variables, specified as a logical vector. The value is true if the variable is categorical.

    VariableInfo also includes any variables not used to fit the model as predictors or as the response.

    Data Types: table

    This property is read-only after object creation.

    Names of the variables, returned as a cell array of character vectors.

    • If the fit is based on a table, this property contains the names of the variables in the table.

    • If the fit is based on a predictor matrix and response vector, this property contains the values specified by the VarNames name-value argument of the fitting method. The default value of VarNames is {'x1','x2',...,'xn','y'}.

    VariableNames also includes any variables not used to fit the model as predictors or as the response.

    Data Types: cell

    Object Functions

    plotSlicePlot of slices through fitted censored linear regression surface
    predictPredict responses of censored linear regression model
    partialDependenceCompute partial dependence
    plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
    fevalPredict responses of censored linear regression model using one input for each predictor
    randomSimulate responses with random noise for censored linear regression model
    coefCIConfidence intervals of coefficient estimates for censored linear regression model
    coefTestLinear hypothesis test on censored linear regression model coefficients

    Examples

    collapse all

    Load the censored readmissiontimes 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)
    mdl = 
    Censored linear regression model
        ReadmissionTime ~ 1 + Age + Weight + Smoker
    
    Estimated Coefficients:
                       Estimate        SE        tStat        pValue  
                       _________    ________    ________    __________
    
        (Intercept)        27.74      3.4008      8.1569    1.4048e-12
        Age            -0.053476    0.059514    -0.89854       0.37117
        Weight          -0.11101    0.016823     -6.5986    2.3484e-09
        Smoker           -2.3455     0.93105     -2.5192      0.013434
    
    Sigma: 4.068
    
    Number of observations: 100, Error degrees of freedom: 95
    25 right-censored observations
    75 uncensored observations
    Likelihood ratio statistic vs. constant model: 45, p-value = 9.27e-10
    

    mdl is a CensoredLinearModel object that contains the results of fitting a linear model to the censored data.

    Compact the model.

    compactMdl = compact(mdl);

    The compact model discards the original sample data and some information related to the fitting process.

    Compare the size of the full model mdl and the compact model compactMdl.

    vars = whos("compactMdl","mdl");
    [vars(1).bytes,vars(2).bytes]
    ans = 1×2
    
            5449       14313
    
    

    The compact model uses less memory than the full model.

    References

    [1] Allison, P. D. Measures of Fit for Logistic Regression, Statistical Horizons LLC and the University of Pennsylvania, 2014.

    [2] Law, M., and Jackson, D. Residual Plots for Linear Regression Models with Censored Outcome Data: A Refined Method for Visualizing Residual Uncertainty, Communications in Statistics - Simulation and Computation, vol. 46, no. 4, pp. 3159–71, 2017.

    Version History

    Introduced in R2025a