coefCI

Class: NonLinearModel

Confidence intervals of coefficient estimates of nonlinear regression model

Syntax

ci = coefCI(mdl)
ci = coefCI(mdl,alpha)

Description

ci = coefCI(mdl) returns confidence intervals for the coefficients in mdl.

ci = coefCI(mdl,alpha) returns confidence intervals with confidence level 1 - alpha.

Input Arguments

 mdl Nonlinear regression model, constructed by fitnlm. alpha Scalar from 0 to 1, the probability that the confidence interval does not contain the true value. Default: 0.05

Output Arguments

 ci k-by-2 matrix of confidence intervals. The jth row of ci is the confidence interval of coefficient j of mdl. The name of coefficient j of mdl is in mdl.CoefNames.

Examples

expand all

Create a nonlinear model for auto mileage based on the carbig data. Then obtain confidence intervals for the resulting model coefficients.

Load the data and create a nonlinear model.

ds = dataset(Horsepower,Weight,MPG);
modelfun = @(b,x)b(1) + b(2)*x(:,1) + ...
b(3)*x(:,2) + b(4)*x(:,1).*x(:,2);
beta0 = [1 1 1 1];
mdl = fitnlm(ds,modelfun,beta0)
mdl =
Nonlinear regression model:
MPG ~ b1 + b2*Horsepower + b3*Weight + b4*Horsepower*Weight

Estimated Coefficients:
Estimate         SE         tStat       pValue
__________    __________    _______    __________

b1        63.558        2.3429     27.127    1.2343e-91
b2      -0.25084      0.027279    -9.1952    2.3226e-18
b3     -0.010772    0.00077381    -13.921    5.1372e-36
b4    5.3554e-05    6.6491e-06     8.0542    9.9336e-15

Number of observations: 392, Error degrees of freedom: 388
Root Mean Squared Error: 3.93
F-statistic vs. constant model: 385, p-value = 7.26e-116

All the coefficients have extremely small $p$-values. This means a confidence interval around the coefficients will not contain the point 0, unless the confidence level is very high.

Find 95% confidence intervals for the coefficients of the model.

ci = coefCI(mdl)
ci = 4×2

58.9515   68.1644
-0.3045   -0.1972
-0.0123   -0.0093
0.0000    0.0001

The confidence interval for b4 seems to contain 0. Examine it in more detail.

ci(4,:)
ans = 1×2
10-4 ×

0.4048    0.6663

As expected, the confidence interval does not contain the point 0.