Group Abstract Group Abstract

Message Boards Message Boards

0
|
6K Views
|
5 Replies
|
6 Total Likes
View groups...
Share
Share this post:

[?] Fit experimental data with some analytic formulas?

Posted 8 years ago
Attachments:
POSTED BY: Robert Poenaru
5 Replies
Posted 8 years ago

For your example:

nlm = NonlinearModelFit[data, {Boole[id == 1] e1[x] + Boole[id == 2] e2[x] + Boole[id == 3] e3[x], a>0 && v>0},
  {a, v}, {id, x}];

From the online documentation:

Documentation on NonlinearModelFit

POSTED BY: Jim Baldwin
Posted 8 years ago

Yes. Restrictions can be added. Again, however, there is the assumption of equal error variance. You could also fit a common value for a and then separate values of v for each dataset.

As a side note, I have noticed a desire from a few others to use the Sum((O-E)^2/E) chisquare approach to regression. That's a bit nonstandard (and usually downright wrong) for regression problems. If the data consists of frequency counts, then such a statistic can make more sense. Maybe there's some textbook in your field that recommends such approaches. (And they must be stopped! ;))

POSTED BY: Jim Baldwin
Posted 8 years ago

Where exactly in this NonLinearModeFit one can add those extra conditions?

POSTED BY: Robert Poenaru
Posted 8 years ago

The objective seems to be a straightforward nonlinear regression. I don't understand why you'd want to construct a chisquared statistic to do so when using NonlinearModelFit will give you want you want directly:

(* Put in an id for each dataset and join all of the data into a single dataset *)
data = Join[Insert[#, 1, 1] & /@ data1, Insert[#, 2, 1] & /@ data2, Insert[#, 3, 1] & /@ data3];

(* Run the nonlinear regression *)
nlm = NonlinearModelFit[data, Boole[id == 1] e1[x] + Boole[id == 2] e2[x] + Boole[id == 3] e3[x], {a, v}, {id, x}];
nlm["BestFitParameters"]
(* {a -> 0.018304629031942354, v -> 0.3633047083635527} *)

This assumes that all of the regressions have the same error variance.

POSTED BY: Jim Baldwin
Posted 8 years ago

Wow. Thank you very much for this solution! I didn't know that you can join multiple data sets and bind them to id's. This solution seems quite elegant :)

It is possible to add some restrictions inside the "NonLinearModelFit"? (Like I did in the minimize function where I had e[x]==something)

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