compact

Class: GeneralizedLinearModel

Compact generalized linear regression model

Syntax

compactMdl = compact(mdl)

Description

compactMdl = compact(mdl) returns a compact generalized linear regression model, compactMdl, which is the compact version of the full, fitted regression model mdl. The compact model uses less memory than the full model because it does not include a copy of the data or anything comparable in size to the data. However, the compact model also does not support properties (such as Residuals) or methods (such as addTerms) that require the data.

Input Arguments

expand all

Full, fitted generalized linear regression model, specified as a GeneralizedLinearModel object constructed using fitglm or stepwiseglm.

Output Arguments

expand all

Compact generalized linear regression model, returned as a CompactGeneralizedLinearModel object.

Predict response values using compactMdl exactly as you would using mdl. However, since compactMdl does not contain training data, you cannot perform certain tasks, such as cross-validation.

Examples

expand all

Reduce the size of a full, fitted generalized linear regression model by discarding the sample data and some information related to the fitting process.

Load the data into the workspace. The simulated sample data contains 15,000 observations and 45 predictor variables.

load(fullfile(matlabroot,'examples','stats','largedata4reg.mat'))

Fit a generalized linear regression model to the data using the first 15 predictor variables.

mdl = fitglm(X(:,1:15),Y)
mdl = 
Generalized linear regression model:
    y ~ [Linear formula with 16 terms in 15 predictors]
    Distribution = Normal

Estimated Coefficients:
                    Estimate          SE         tStat       pValue   
                   ___________    __________    _______    ___________

    (Intercept)         3.2903    0.00010447      31497              0
    x1              -0.0006461    4.9991e-08     -12924              0
    x2             -0.00024739    8.6874e-08    -2847.7              0
    x3             -9.5161e-05    1.1138e-07    -854.38              0
    x4              0.00013143     1.551e-07     847.35              0
    x5               7.163e-05    1.9793e-07      361.9              0
    x6              4.5064e-06    2.2247e-07     20.257     4.9539e-90
    x7             -2.6258e-05    2.5462e-07    -103.13              0
    x8               6.284e-05    2.5633e-07     245.15              0
    x9             -0.00014288     2.817e-07    -507.19              0
    x10            -2.2642e-05    3.0963e-07    -73.127              0
    x11            -6.0227e-05    3.1639e-07    -190.36              0
    x12             1.1665e-05    3.3921e-07     34.388    1.6995e-249
    x13             3.8595e-05    3.5601e-07     108.41              0
    x14             0.00010021    4.0312e-07     248.57              0
    x15            -6.5674e-06    4.1692e-07    -15.752      1.844e-55


15000 observations, 14984 error degrees of freedom
Estimated Dispersion: 0.000164
F-statistic vs. constant model: 1.18e+07, p-value = 0

Compact the model. The compact model discards the original sample data and some information related to the fitting process, so it uses less memory than the full model.

compactMdl = compact(mdl)
compactMdl = 
Compact generalized linear regression model:
    y ~ [Linear formula with 16 terms in 15 predictors]
    Distribution = Normal

Estimated Coefficients:
                    Estimate          SE         tStat       pValue   
                   ___________    __________    _______    ___________

    (Intercept)         3.2903    0.00010447      31497              0
    x1              -0.0006461    4.9991e-08     -12924              0
    x2             -0.00024739    8.6874e-08    -2847.7              0
    x3             -9.5161e-05    1.1138e-07    -854.38              0
    x4              0.00013143     1.551e-07     847.35              0
    x5               7.163e-05    1.9793e-07      361.9              0
    x6              4.5064e-06    2.2247e-07     20.257     4.9539e-90
    x7             -2.6258e-05    2.5462e-07    -103.13              0
    x8               6.284e-05    2.5633e-07     245.15              0
    x9             -0.00014288     2.817e-07    -507.19              0
    x10            -2.2642e-05    3.0963e-07    -73.127              0
    x11            -6.0227e-05    3.1639e-07    -190.36              0
    x12             1.1665e-05    3.3921e-07     34.388    1.6995e-249
    x13             3.8595e-05    3.5601e-07     108.41              0
    x14             0.00010021    4.0312e-07     248.57              0
    x15            -6.5674e-06    4.1692e-07    -15.752      1.844e-55


15000 observations, 14984 error degrees of freedom
Estimated Dispersion: 0.000164
F-statistic vs. constant model: 1.18e+07, p-value = 0

Introduced in R2016b