Group Abstract Group Abstract

Message Boards Message Boards

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

Why does my fit not work?

Posted 11 years ago
POSTED BY: Peter Parker
6 Replies
Posted 11 years ago

As Henrik shows, Mathematica is performing properly.

However, you really need to consider a better model or additional data. If "prediction" is the most important objective, then using ListInterpolation (in this case where there is so little variability about the line) works great:

f = ListInterpolation[FresnelFit1[[All, 2]], {FresnelFit1[[All, 1]]}];
Show[{ListPlot[FresnelFit1, Frame -> True, 
   PlotRange -> {Automatic, {0.0071, 0.0077}}, 
   PlotStyle -> {Red, PointSize[0.01]}], 
  Plot[f[\[Lambda]], {\[Lambda], Min[FresnelFit1[[All, 1]]], 
    Max[FresnelFit1[[All, 1]]]}, PlotStyle -> Blue]}, 
 ImageSize -> Large]

model fit

For noisier data a nonparametric fit (such as a gam - generalized additive model) would be better. However, Mathematica as far as I know does not supply a gam function or other nonparametric fits (Developers: Please!).

If interpretation of the coefficients is a more important objective, then you need a different model as there is a not a good fit and there's no point in interpreting coefficients or providing estimates of coefficients of a poorly fitting model. Something must be missing in the model or in how the data is actually generated.

My experience is in fields were large amounts of variability is the expected norm. If I saw such data in one of those fields, I would wonder if all of the observations are highly serially correlated and in such a case the NonlinearModelFit is inappropriate as it does not allow for serial correlation. Is the data from a single run of some measurement process? If so, I'd say you have a sample size of one and would need replication of the measurement process to fight off the claim (at least potentially) that the model as presented is not a good fit. But here, too, with multiple sets of measurements, NonlinearModelFit does not handle mixed models (i.e., where there is more than one source of variability: between sets of measurements and serial correlation). Adding mixed models to Mathematica's repertoire would also be great.

POSTED BY: Jim Baldwin

Hi Peter,

I cannot see any problem:

n = 1.46; L = 0.001002;

model = ((1 - r1^2)*(1 - r2^2))/((1 - r1*r2)^2 + 
      4*r1*r2 (Sin[(((2 \[Pi] 10^6)/(\[Lambda])) 2 n L Cos[\[Theta]])/
           2])^2)*I0;

nlm = NonlinearModelFit[FresnelFit1, 
   model, {{r1, 0.30}, {r2, 0.30}, {I0, 0.0077}, {\[Theta], 
     2.0}}, \[Lambda], MaxIterations -> Automatic];

Show[ListLinePlot[FresnelFit1, PlotStyle -> {Green, Dashed}],
 Plot[nlm[\[Lambda]], {\[Lambda], 1.549, 1.55}]]

which gives:

enter image description here

Well, I slightly changed the initial values of the r's and the number of MaxIterations, but that does not make a significant difference.

Tschau! ... Henrik

POSTED BY: Henrik Schachner

Oh sorry, seems that I forgot to mention that

n=1.46; L=0.001002;

I also added this information to my first post.

Furthermore I think by copy and paste the numbers of my list, the value (last digits) changed. This is why your ListPlot does not look like my ListPlot in the first post. Therefore I also changed this in my first post. If you plot the data now, they should look like in my first figure.

Yes, the equation should be correct. I checked it and it makes sense.

POSTED BY: Peter Parker
Posted 11 years ago

It looks like the constants n and L are missing from your example code. And the plot of the data doesn't look like a perfect fit to the dashed line:

ListPlot[FresnelFit1, Frame -> True]

produces

scatter plot

POSTED BY: Jim Baldwin
Posted 5 years ago

5 years past, there's still no GAM model built in.

POSTED BY: Jason Zhao
Posted 11 years ago
POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard