Linear hypothesis test on nonlinear regression model coefficients
Test Nonlinear Regression Model Coefficients
Make a nonlinear model of mileage as a function of the weight from the
carsmall data set. Test the coefficients to see if all should be zero.
Create an exponential model of car mileage as a function of weight from the
carsmall data. Scale the weight by a factor of 1000 so all the variables are roughly equal in size.
load carsmall X = Weight; y = MPG; modelfun = 'y ~ b1 + b2*exp(-b3*x/1000)'; beta0 = [1 1 1]; mdl = fitnlm(X,y,modelfun,beta0);
Test the model for significant differences from a constant model.
p = coefTest(mdl)
p = 1.3708e-36
There is no doubt that the model contains nonzero terms.
The p-value, F statistic, and numerator degrees of freedom are valid under these assumptions:
The data comes from a normal distribution.
The entries are independent.
Suppose these assumptions hold. Let β represent the unknown coefficient vector of the linear regression. Suppose H is a full-rank numeric index matrix of size r-by-s, where r is the number of linear combinations of coefficients being tested, and s is the number of terms in β. Let c be a vector the same size as β. The following is a test statistic for the hypothesis that Hβ = c:
Here is the estimate of the coefficient vector β in
mdl.Coefs, and V is the estimated
covariance of the coefficient estimates in
mdl.CoefCov. When the
hypothesis is true, the test statistic F has an F Distribution with r and u
degrees of freedom.
The values of commonly used test statistics are available in the
Introduced in R2012a