Main Content

coefTest

Class:NonLinearModel

Linear hypothesis test on nonlinear regression model coefficients

Syntax

p = coefTest(mdl)
p = coefTest(mdl,H)
p = coefTest(mdl,H,C)
[p,F] = coefTest(mdl,...)
[p,F,r] = coefTest(mdl,...)

Description

p= coefTest(mdl)computes thep价值的Ftest that all coefficient estimates inmdlare zero.

p= coefTest(mdl,H)performs anFtest thatH*B = 0, whereBrepresents the coefficient vector.

p= coefTest(mdl,H,C)performs anFtest thatH*B = C.

[p,F] = coefTest(mdl,...)returns theFtest statistic.

[p,F,r] = coefTest(mdl,...)returns the numerator degrees of freedom for the test.

Input Arguments

mdl

Nonlinear regression model, constructed byfitnlm.

H

Numeric matrix having one column for each coefficient in the model. WhenHis an input, the outputpp价值的Ftest thatH*B = 0, whereBrepresents the coefficient vector.

C

Numeric vector with the same number of rows asH. WhenCis an input, the outputpp价值的Ftest thatH*B = C, whereBrepresents the coefficient vector.

Output Arguments

p

p-value of theFtest (seeMore About).

F

Value of the test statistic for theFtest (seeMore About).

r

Numerator degrees of freedom for theFtest (seeMore About). TheFstatistic hasrdegrees of freedom in the numerator andmdl.DFEdegrees of freedom in the denominator.

Examples

expand all

Make a nonlinear model of mileage as a function of the weight from thecarsmalldata set. Test the coefficients to see if all should be zero.

Create an exponential model of car mileage as a function of weight from thecarsmalldata. Scale the weight by a factor of 1000 so all the variables are roughly equal in size.

loadcarsmallX = 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.

More About

expand all

Alternatives

The values of commonly used test statistics are available in themdl.Coefficientstable.