Categories &

Functions List

Class Definition: NonLinearModel

statistics: NonLinearModel

Nonlinear regression model class.

A NonLinearModel object holds a nonlinear regression fitted by fitnlm, together with its coefficients, fit statistics, and methods for inference, prediction, and diagnostics. Construct one with fitnlm, which documents the accepted inputs and Name/Value pairs.

The estimated coefficients and their statistics are in the Coefficients table; Rsquared, ModelCriterion, LogLikelihood, RMSE, SSE, SST, and SSR summarize the fit. The methods predict, feval, random, coefCI, coefTest, plotResiduals, plotDiagnostics, and plotSlice operate on the fitted model.

Fit statistics

The fit statistics follow MATLAB’s conventions. SSE is the residual sum of squares, SST the total sum of squares of the response about its (weighted) mean, and SSR the regression sum of squares of the fitted values about that mean; because the model is nonlinear, SST does not in general equal SSR + SSE. Rsquared.Ordinary is 1 - SSE / SST and Rsquared.Adjusted corrects for the error degrees of freedom. RMSE is sqrt (MSE), and the Gaussian LogLikelihood uses the maximum-likelihood error variance SSE / n. The information criteria in ModelCriterion (AIC, AICc, BIC, CAIC) count the p coefficients as the only parameters – the error variance is not counted. coefTest is a Wald test: for a contrast matrix H it forms (H*b)' * inv (H*V*H') * (H*b) / r with V the coefficient covariance and r the number of rows of H, referred to an F distribution on r and DFE degrees of freedom. The summary printed by disp instead reports an F statistic versus the zero model, formed from the uncorrected regression sum of squares (the sum of the squared fitted values).

See also: fitnlm, nlinfit, nlparci, nlpredci, LinearModel, GeneralizedLinearModel

Source Code: NonLinearModel

The NonLinearModel class contains the following properties:

A table with one row per coefficient, its row names taken from CoefficientNames, and the variables Estimate, SE, tStat and pValue. tStat is the estimate divided by its standard error and pValue is the two-sided t test of a zero coefficient on DFE degrees of freedom. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A cell array of character vectors with one name per coefficient, in the order the model function expects them. The names default to 'b1', 'b2' and so on, unless fitnlm was given a list of its own. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A square numeric matrix, one row and column per coefficient, holding the estimated covariance of the estimates in Coefficients. The square roots of its diagonal are the standard errors reported in column SE of that table. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A positive integer counting the coefficients of the model, which is the number of elements of the starting vector handed to fitnlm. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A positive integer counting the coefficients estimated from the data. A nonlinear fit estimates every coefficient it carries, so this equals NumCoefficients. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A positive integer counting the predictor variables, that is the columns of the predictor matrix used for the fit. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A positive integer counting the observations used for the fit, after the rows named by 'Exclude' and the rows carrying missing values have been dropped. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A nonnegative integer, NumObservations less NumCoefficients. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A positive scalar holding the estimated variance of the error term. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A positive scalar, the square root of MSE. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A nonnegative scalar, the sum of the squared residuals weighted by the observation weights. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A nonnegative scalar, the weighted sum of squared deviations of the response about its weighted mean. Because the model is nonlinear, SST does not in general equal SSR plus SSE. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A nonnegative scalar, the weighted sum of squared deviations of the fitted values about the weighted mean of the response. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A scalar, the Gaussian log-likelihood at the estimates, formed with the maximum-likelihood error variance SSE divided by NumObservations. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A scalar structure with the fields AIC, AICc, BIC and CAIC. All four count the coefficients as the only parameters; the error variance is not counted. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A scalar structure with the fields Ordinary and Adjusted. Ordinary is one less the ratio of SSE to SST, and Adjusted corrects that ratio for the error degrees of freedom. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A table with one row per observation used for the fit and the variables Raw, Pearson, Standardized and Studentized. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A numeric column vector with one fitted value per observation used for the fit. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

Empty when the model was fitted by ordinary least squares. When fitnlm was given a robust weight function, a scalar structure whose field RobustWgtFun names it. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A character vector showing the fitted model, built from the model function together with the coefficient names and the response name. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A character vector naming the response. It defaults to 'y' for a fit from matrices and is the name of the response column for a fit from a table. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A cell array of character vectors with one name per predictor. The names default to 'x1', 'x2' and so on for a fit from matrices, and are the column names for a fit from a table. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

A cell array of character vectors holding PredictorNames followed by ResponseName. This property is read-only.

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

The NonLinearModel class offers the following public methods:

NonLinearModel: mdl = NonLinearModel (data, resp, modelfun, beta0)
NonLinearModel: mdl = NonLinearModel (…, Name, Value)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: yhat = predict (mdl, Xnew)
NonLinearModel: [yhat, yci] = predict (mdl, Xnew)
NonLinearModel: […] = predict (…, Name, Value)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: yhat = feval (mdl, X)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: ysim = random (mdl, Xnew)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: ci = coefCI (mdl)
NonLinearModel: ci = coefCI (mdl, alpha)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: [p, F, df] = coefTest (mdl)
NonLinearModel: […] = coefTest (mdl, H)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: h = plotResiduals (mdl)
NonLinearModel: h = plotResiduals (mdl, plottype)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: h = plotDiagnostics (mdl)
NonLinearModel: h = plotDiagnostics (mdl, plottype)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689
NonLinearModel: h = plotSlice (mdl)

Fit an exponential growth model y = b1 exp (b2 x) and inspect it.

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689

Examples

 x = (1:10)';
 y = [2.1; 2.9; 4.2; 5.3; 7.1; 9.4; 12.8; 16.5; 22.1; 29.8];
 modelfun = @(b, x) b(1) .* exp (b(2) .* x);
 mdl = fitnlm (x, y, modelfun, [1; 0.3]);
 disp (mdl.Coefficients)
  2x4 table

          Estimate        SE         tStat       pValue       
          ________    __________    _______    ___________    

    b1     1.68375     0.0351945    47.8412    4.03037e-11    
    b2    0.286911    0.00235084    122.046    2.27082e-14
 printf ("RMSE = %g,  R^2 = %g\n", mdl.RMSE, mdl.Rsquared.Ordinary);
RMSE = 0.170943,  R^2 = 0.999689