gather

Gather properties of linear or generalized linear regression model

    Description

    example

    gatheredMdl = gather(mdl) gathers all properties of the input linear or generalized linear model mdl and returns the gathered model gatheredMdl. All properties of the output model are stored as regular arrays.

    Use gather to create a linear or generalized linear model with properties stored as regular arrays from a model fitted using data stored as a GPU array. For more details on GPU arrays, see gpuArray (Parallel Computing Toolbox).

    Examples

    collapse all

    Gather the properties of a linear regression model fitted with GPU array data.

    Load the carsmall data set. Create X as a numeric matrix that contains three car performance metrics. Create Y as a numeric vector that contains the corresponding miles per gallon.

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

    Convert the predictor X and response Y to gpuArray (Parallel Computing Toolbox) objects.

    X = gpuArray(X);
    Y = gpuArray(Y);

    Fit a linear regression model mdl by using fitlm.

    mdl = fitlm(X,MPG);

    Display the coefficients of mdl and determine whether the estimated coefficient values are GPU arrays.

    mdl.Coefficients
    ans=4×4 table
                        Estimate        SE          tStat        pValue  
                       __________    _________    _________    __________
    
        (Intercept)        47.977       3.8785        12.37    4.8957e-21
        x1             -0.0065416    0.0011274      -5.8023    9.8742e-08
        x2              -0.042943     0.024313      -1.7663       0.08078
        x3              -0.011583      0.19333    -0.059913       0.95236
    
    
    isgpuarray(mdl.Coefficients.Estimate)
    ans = logical
       1
    
    

    Gather the properties of the linear regression model.

    gatheredMdl = gather(mdl);

    Display the coefficients of gatheredMdl and determine whether the estimated coefficient values are GPU arrays.

    gatheredMdl.Coefficients
    ans=4×4 table
                        Estimate        SE          tStat        pValue  
                       __________    _________    _________    __________
    
        (Intercept)        47.977       3.8785        12.37    4.8957e-21
        x1             -0.0065416    0.0011274      -5.8023    9.8742e-08
        x2              -0.042943     0.024313      -1.7663       0.08078
        x3              -0.011583      0.19333    -0.059913       0.95236
    
    
    isgpuarray(gatheredMdl.Coefficients.Estimate)
    ans = logical
       0
    
    

    Input Arguments

    collapse all

    Linear or generalized linear regression model, specified as a LinearModel, CompactLinearModel, GeneralizedLinearModel, or CompactGeneralizedLinearModel object.

    You can create a linear or generalized linear regression model that supports GPU arrays in these ways:

    • Use fitlm to create a LinearModel object fitted with GPU array input arguments.

    • Use compact to create a CompactLinearModel object from a LinearModel object fitted with GPU array input arguments.

    • Use fitglm to create a GeneralizedLinearModel object fitted with GPU array input arguments.

    • Use compact to create a CompactGeneralizedLinearModel object from a GeneralizedLinearModel object fitted with GPU array input arguments.

    Extended Capabilities

    Introduced in R2020b