Message Boards Message Boards

0
|
6443 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Why RSquared for LinearFitModel and NonLinearFitModel are different?

Posted 8 years ago

Good day,

In WM I made next computations: - data generation -{{x1,y1},{x2,y3},{x3,y3},...,{xn,yn},} -building a model by LinearModelFit and NonlinearModelFit model. Why the RSquared value are different for these two models? NOTE:In NonLinearModelFit set model a+bx^1.

Below is the code:

(*data generation*)
data = Table[{i, 5 + 5*i + RandomReal[{-55, 55}]}, {i, 1, 50}];
(*building a model by LinearModelFit and NonLinearModelFit model*)
nolm = NonlinearModelFit[data, a + b *x^1, {a, b}, x]
lm = LinearModelFit[data, x, x]
(*Plotting points and models*)
Row[{Show[ListPlot[data, ImageSize -> Large], Plot[lm[x], {x, 1, 50}],
     Frame -> True]
   Show[ListPlot[data, ImageSize -> Large], Plot[nolm[x], {x, 1, 50}],
     Frame -> True]}]
(* RSquared for LinearModelFit, Correlation coeficient, RSquared for \
NonLinearModelFit*)
{lm["RSquared"],
 Correlation[data[[All, 1]], data[[All, 2]]],
 nolm["RSquared"]}

Thank you in advance

Attachments:
POSTED BY: Anton Ekimenko

At the bottom of this page The difference of R squared of Nonlinear model fit and that of linear model fit is explained.

POSTED BY: Shenghui Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract