Main Content

CompactRegressionQuantileLinear

Compact quantile linear regression model

Since R2025a

    Description

    CompactRegressionQuantileLinear is a compact version of a RegressionQuantileLinear model object. The compact model does not include the data used for training the quantile regression model. Therefore, you cannot use the compact model to perform certain tasks, such as cross-validation. Use the compact model for tasks such as predicting the response values of new data.

    Creation

    Create a CompactRegressionQuantileLinear object from a full RegressionQuantileLinear model object by using the compact function.

    Properties

    expand all

    Linear Regression Properties

    This property is read-only.

    Quantiles used to train the quantile linear regression model, returned as a vector of values in the range [0,1].

    Data Types: double

    This property is read-only.

    Linear coefficient estimates, returned as a numeric matrix. Each row corresponds to an expanded predictor (ExpandedPredictorNames), and each column corresponds to a quantile (Quantiles).

    Data Types: double

    This property is read-only.

    Estimated bias terms or model intercepts, returned as a numeric vector. Each element corresponds to a quantile (Quantiles).

    Data Types: double

    This property is read-only.

    Regularization term strength for the ridge (L2) penalty, returned as a nonnegative scalar. The software uses the same regularization term strength for all quantiles.

    Data Types: double | single

    This property is read-only.

    Objective function minimization technique used to train the quantile linear regression model, returned as 'bfgs' or 'lbfgs'.

    Data Types: char

    Data Properties

    This property is read-only.

    Predictor variable names, returned as a cell array of character vectors. The order of the elements of PredictorNames corresponds to the order in which the predictor names appear in the training data.

    Data Types: cell

    This property is read-only.

    Categorical predictor indices, returned as a vector of positive integers. Assuming that the predictor data contains observations in rows, CategoricalPredictors contains index values corresponding to the columns of the predictor data that contain categorical predictors. If none of the predictors are categorical, then this property is empty ([]).

    Data Types: double

    This property is read-only.

    Expanded predictor names, returned as a cell array of character vectors. If the model uses encoding for categorical variables, then ExpandedPredictorNames includes the names that describe the expanded variables. Otherwise, ExpandedPredictorNames is the same as PredictorNames.

    Data Types: cell

    This property is read-only.

    Predictor means, returned as a numeric vector. If you set Standardize to 1 or true when you train the linear model, then the length of the Mu vector is equal to the number of expanded predictors (ExpandedPredictorNames). The vector contains 0 values for dummy variables corresponding to expanded categorical predictors.

    If you set Standardize to 0 or false when you train the linear model, then the Mu value is an empty vector ([]).

    Data Types: double

    This property is read-only.

    Predictor standard deviations, returned as a numeric vector. If you set Standardize to 1 or true when you train the linear model, then the length of the Sigma vector is equal to the number of expanded predictors (ExpandedPredictorNames). The vector contains 1 values for dummy variables corresponding to expanded categorical predictors.

    If you set Standardize to 0 or false when you train the linear model, then the Sigma value is an empty vector ([]).

    Data Types: double

    This property is read-only.

    Response variable name, returned as a character vector.

    Data Types: char

    Response transformation function, specified as "none" or a function handle. ResponseTransform describes how the software transforms raw response values.

    For a MATLAB® function or a function that you define, enter its function handle. For example, you can enter Mdl.ResponseTransform = @function, where function accepts a numeric vector of the original responses and returns a numeric vector of the same size containing the transformed responses.

    Data Types: char | string | function_handle

    Object Functions

    lossLoss for quantile linear regression model
    predictPredict response for quantile linear regression model

    Examples

    collapse all

    Reduce the size of a full quantile linear regression model by removing the training data. Full quantile regression models include the training data. You can use a compact quantile regression model to improve memory efficiency.

    Load the carbig data set, which contains measurements of cars made in the 1970s and early 1980s. Create a matrix X containing the predictor variables Acceleration, Displacement, Horsepower, and Weight. Store the response variable MPG in the variable Y.

    load carbig
    X = [Acceleration,Displacement,Horsepower,Weight];
    Y = MPG;

    Delete rows of X and Y where either array has missing values.

    R = rmmissing([X Y]);
    X = R(:,1:end-1);
    Y = R(:,end);

    Train a quantile linear regression model. Specify to use the 0.25, 0.50, and 0.75 quantiles (that is, the lower quartile, median, and upper quartile). To improve the model fit, change the beta tolerance to 1e-6 instead of the default value 1e-4, and use a ridge (L2) regularization term of 1.

    Mdl = fitrqlinear(X,Y,Quantiles=[0.25,0.50,0.75], ...
        BetaTolerance=1e-6,Lambda=1)
    Mdl = 
      RegressionQuantileLinear
                 ResponseName: 'Y'
        CategoricalPredictors: []
            ResponseTransform: 'none'
                         Beta: [4×3 double]
                         Bias: [17.0306 22.5291 29.0044]
                    Quantiles: [0.2500 0.5000 0.7500]
    
    
      Properties, Methods
    
    

    Mdl is a RegressionQuantileLinear model object.

    Reduce the size of the quantile regression model.

    CompactMdl = compact(Mdl)
    CompactMdl = 
      CompactRegressionQuantileLinear
                 ResponseName: 'Y'
        CategoricalPredictors: []
            ResponseTransform: 'none'
                         Beta: [4×3 double]
                         Bias: [17.0306 22.5291 29.0044]
                    Quantiles: [0.2500 0.5000 0.7500]
    
    
      Properties, Methods
    
    

    CompactMdl is a CompactRegressionQuantileLinear model object.

    Display the amount of memory used by each model.

    whos("Mdl","CompactMdl")
      Name            Size            Bytes  Class                                                     Attributes
    
      CompactMdl      1x1              4936  classreg.learning.regr.CompactRegressionQuantileLinear              
      Mdl             1x1             26426  RegressionQuantileLinear                                            
    

    The full quantile linear regression model (Mdl) is more than five times larger than the compact quantile linear regression model (CompactMdl).

    To predict the response for new observations efficiently, you can remove Mdl from the MATLAB® Workspace, and then pass CompactMdl and new predictor values to predict.

    Version History

    Introduced in R2025a