Extract model's p-value from fitnlm

12 views (last 30 days)
Dear all,
I am using the Statistical Toolbox (Matlab2013b) to perform a regression analysis. Using apply different regression functions to my dataset (linear,quadratic,exponential) using "fitnlm". I want to choose the best function based on R^2 and p-value. The R^2 is found in the model's output fields. The overall p-value I can't find though it is displayed in the command window: Nonlinear regression model, e.g.:
y ~ b1*x1^2 + b2*x1 + b3
Estimated Coefficients:
Estimate SE tStat pValue
b1 0.02495 0.010583 2.3575 0.027708
b2 -0.75062 1.0529 -0.71294 0.48337
b3 14.633 24.854 0.58877 0.56201
Number of observations: 25, Error degrees of freedom: 22 Root Mean Squared Error: 8.27 R-Squared: 0.897, Adjusted R-Squared 0.887 F-statistic vs. constant model: 95.5, p-value = 1.43e-11
My tool should extract the model p-value = 1.43e-11 automatically (not the individual coefficients' pValue in the table). How can I do this?
Thanks!

Accepted Answer

Bennett Landman
Bennett Landman on 1 Aug 2018
In 2016a, this information is accessible via: mdl.Coefficients.pValue (assuming that mdl is the structure returned by fitnlm).

More Answers (2)

dpb
dpb on 14 Apr 2014
My release doesn't include fitnlm so can't test but doc page indicates that you can recompute the p-values of the various statistics via the coeftest method although the value doesn't seem to be returned as a property.
  1 Comment
Steven
Steven on 14 Apr 2014
Correct, the coefTest function calculates the p-value as well. The outcome is slightly different though. Probably a different approach is used. I think I'll just use the coefTest.

Sign in to comment.


the cyclist
the cyclist on 14 Apr 2014
It seems to me from the documentation that the p-value is not an output.
The F-test calculation is in the file NonLinearModel.m. [Lines 800-834 is the ftest() function in R2014a.] I haven't checked, but it looks like you might be able to reconstruct the p-value from the other outputs.
  2 Comments
Steven
Steven on 14 Apr 2014
Thank you for the help! How can I open this NonLinearModel.m file?
the cyclist
the cyclist on 14 Apr 2014
Type
edit NonLinearModel
at the command prompt
(Be careful not to make changes. You might want to copy that another file.)

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!