# Problem creating MeanPredictionBands

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:

````ClearAll[msymm2fit];
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"}]

MyFit2["BestFitParameters"]
MyFit2["MeanPredictionBands"]
````

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

````ComplexExpand[Re[]]
````

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
Helping you would be difficult if you won't mention either the function or the data... – J. M.♦ Nov 21 '12 at 14:44
– Ludwig Nov 21 '12 at 15:11
@Ludwig It would be better if you could just paste the code in your question. – VLC Nov 21 '12 at 15:25
How does your comment about `ComplexExpand` cast light on your problem. Seems irrelevant to me. – m_goldberg Nov 21 '12 at 15:42
I added a reduced code sample from the file you linked. – Sjoerd C. de Vries Nov 21 '12 at 17:06
show 1 more comment

## 1 Answer

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
````

-

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? – Sjoerd C. de Vries Nov 21 '12 at 17:40
Yes, I just removed the minus sign using $\Re\left(\log(z)\right) = \log\left(|z|\right)$. – Sasha Nov 21 '12 at 17:47
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. – Ludwig Nov 22 '12 at 9:15
lang-mma
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9045544862747192, "perplexity_flag": "middle"}