I have a problem creating MeanPredictionBands for my function which I fitted using NonlinearModelFit. I have a complex-valued function and I am fitting the real part of the function. Mathematica 8 gives me back a fitted function and with it the BestFitParameters. But as soon as I try to feed it the "MeanPredictionBands" command, it gives me back the following line:

Experimental`NumericalFunction::nnum: The function [...] is not a number at {fitparameters}.

I have also tried using the ComplexExpand function on the real part of my function, which still doesn't help with my situation. Has anybody encountered this particular problem before? All my variables are real, as are the fit parameters.

Thank you all for your help!

From the file linked in comment a reduced code sample that exhibits the same problem:

msymm2fit =  Re[0.145` mV^6 Log[-(0.5929`/mV^2)] + 12 b0V \[Nu]^2 + 8 bDV \[Nu]^2]

MyData2 = {{0.332, 0.807^2}, {0.386, 0.821^2}, {0.447, 0.855^2}};
MyError2 = {0.027, 0.011, 0.029};
MyFit2 = NonlinearModelFit[MyData2, msymm2fit, {mV, b0V, bDV}, \[Nu], 
  VarianceEstimatorFunction -> (1 &), Weights -> 1/(MyError2)^2, 
  Method -> {NMinimize, Method -> "DifferentialEvolution"}]


The inability to create the Bands apparently comes simply from taking the Real part of the function. I tried this out on another, really easy function. If you take


of a real valued function, this problem with creating the error bands goes away.

In my case, taking the Real part analytically (i.e. by hand) is not that easy, since it is created while i am fitting the data.

TL;DR Simply taking the Real part of any function will hinder Mathematica 8 from creating error bands from the fitted function.

  • 5
    $\begingroup$ Helping you would be difficult if you won't mention either the function or the data... $\endgroup$ – J. M. will be back soon Nov 21 '12 at 14:44
  • $\begingroup$ I have prepared a download-link for a very simplified version of the worksheet: Example.nb $\endgroup$ – Ludwig Nov 21 '12 at 15:11
  • $\begingroup$ @Ludwig It would be better if you could just paste the code in your question. $\endgroup$ – VLC Nov 21 '12 at 15:25
  • $\begingroup$ How does your comment about ComplexExpand cast light on your problem. Seems irrelevant to me. $\endgroup$ – m_goldberg Nov 21 '12 at 15:42
  • $\begingroup$ I added a reduced code sample from the file you linked. $\endgroup$ – Sjoerd C. de Vries Nov 21 '12 at 17:06

Please report this issue to support@wolfram.com. Meanwhile observe that changing mysymm2fit to get rid of Re makes the issue go away:

msymm2fit = 
 0.145` mV^6 Log[(0.5929`/mV^2)] + 12 b0V \[Nu]^2 + 8 bDV \[Nu]^2

enter image description here

  • $\begingroup$ I removed about five lines of code from the OP's original function definition to get a usable, small example. I assume, but haven't checked this, that the Re is necessary in the original version and cannot be so easily removed there. BTW: did you just throw away a minus sign in the Log, or did I miss something? $\endgroup$ – Sjoerd C. de Vries Nov 21 '12 at 17:40
  • $\begingroup$ Yes, I just removed the minus sign using $\Re\left(\log(z)\right) = \log\left(|z|\right)$. $\endgroup$ – Sasha Nov 21 '12 at 17:47
  • $\begingroup$ This still does not solve my problem, because I cannot take the Real part by hand. So far, nothing I tried works, but I sent an email to Wolframs support, let's see what they come up with. $\endgroup$ – Ludwig Nov 22 '12 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.