Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to get what I call a "$\chi^2$ fit". This means taking a function $f(x,p)$ of the variable $x$ with a parameter $p$ and finding the value of $p$ that minimizes the "distance" from a data set $\{x_i, d_i\}$, i.e. minimizes the quantity

$$\chi^2=\frac{\left(f(x_i,p) - d_i\right)^2}{d_i}$$

See this Yale course notes for a reference.

You can find the value of the parameter $p$ with NMinimize, of course, or use NonlinearModelFit. I figured out that to get the same result, i.e. perform the same minimization, you need to use

nlm = NonlinearModelFit[data, 1 + p x^2, {p}, x, Weights -> (1/#2 &)]

where I have taken f[x,p] = 1 + p*x^2 just to give an example

This procedure is supposed to give you the best estimate of the parameter $p$ and an error is associated to to this estimate. I thought that nlm["ParameterErrors"] would give this error, but I do not find any documentation for this.

Usually, for a one parameter estimation at 68% confidence level, the error comes from looking at the curve $\chi^2=1+\chi_\min^2$ where $\chi_\min^2$ is the value of the function $\chi^2$ for the parameter $p$ that minimizes $\chi^2$ (in other words the value at the best fit).

By direct computation and confronting with "ParameterErrors" it seems that "ParameterErrors" does not give this type of error estimate.

Now, is anybody aware of what exactly "ParameterErrors" does and how to instruct NonlinearModelFit to do what I need to do?

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.