How to calculate p value after using fminsearch

I used the fminsearch to fit my data with an exponential equation. Is there a way to calculate the p value of that fitting? ( the fminsearch doesn't seem to have R2 or p attach to it)

 Accepted Answer

Using fminsearch it will be necessary to create your own covariance matrix (for the confidence interval calculations) and analysis-of-variance statistics. The Statistics and Machine Learning Toolbox functions (specifically, fitnlm would likely be appropriate here) will do all those calculations for you and return the results.

6 Comments

I checked out the fitnlm, but I am still not sure what input should I give it in orger to get the P value. I have already had R2 calculated by hand, and the fitted exponential function, and also the original data points. Do you mind specify how I should used those to calculate the P with the toolbox? Thanks.
Just give it the independent and dependent variable vectors (I believe it and its friends require column vectors) and it will do everything else on its own.
See the documentation I linked to for a description of how to use it, what it produces, and how to get specific details of the output summary it produces. All that is in the (quite extensive) documentation and the linked documentation.
I looked throught the documentation and it works~ Thanks very much!
As always, my pleasure!
Hello. Sorry for asking in the middle of this nice conversation. Where I can get the link that @Star Strider means of "See the documentation I linked to for a description oh how to use it" ?
Thank you.
@Darin Sabrina — That would likely be the link to fitnlm, since I don’t see links to any other documentation in my Answer or Comments. It should be available by clicking on the link. I just tested it and found that it works.

Sign in to comment.

More Answers (0)

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!