Comparing 2 linear models

5 views (last 30 days)
patrick Joyce
patrick Joyce on 7 Aug 2015
Edited: Walter Roberson on 7 Aug 2015
Hi, I need to compare whether 2 linear models are significantly different from each other. I am fairly new to Matlab and am struggling to understand why I can't get a difference. Here is my code:
Good = isnan(yh_col) + isnan(u_col);
mdl = fitlm(yh_col(Good==0), u_col(Good==0), 'poly3');
figure
plot (mdl)
Goodf = isnan(yf_col) + isnan(ufished_col);
mdlf = fitlm(yf_col(Goodf==0), ufished_col(Goodf==0), 'poly3');
hold on
plot (yf_col, ufished_col, 'bo')
plot (mdlf)
hold off
anova2(mdl, mdlf)
As I say, I have 2 linear models and wish to compare their differences.
Any help is greatly appreciated!
Thanks.
  1 Comment
Uladzimir
Uladzimir on 7 Aug 2015
Hi Patrick. I would recommend you to try "compare" function.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!