Extract model's p-value from fitnlm
12 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
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).
0 Comments
More Answers (2)
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.
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
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.)
See Also
Categories
Find more on Specification Testing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!