MPFIT: 95% Confidence Interval ? [message #90206] |
Tue, 10 February 2015 16:20  |
limiqt
Messages: 27 Registered: October 2013
|
Junior Member |
|
|
Hi everyone,
I was wondering if someone knows how to plot the 95% CI using the MPFIT curve fitting (http://www.physics.wisc.edu/~craigm/idl/fitting.html).
In the example I can fit my model but now I need to plot the 95% CI as well as the prediction intervals.
;====
Pro fitmydata
X=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Y=[5, 10, 6, 20, 30, 20, 60, 90, 70, 100]
expr='P[0]*(X^P[1])'
start = [1D, 0.5]
Yfit = MPFITEXPR(expr, X, Y, 1, start)
fitS=Yfit(0)*(X^Yfit(1))
cgwindow
cgplot, X, Y, psym=16,symsize=1, /noerase, /AddCMD
cgoplot,X, fitS, thick=2, color='red',/AddCMD
End
;====
I will appreciate any assistance,
Thanks,
Lim
|
|
|
|
Re: MPFIT: 95% Confidence Interval ? [message #90216 is a reply to message #90206] |
Wed, 11 February 2015 13:44  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Tuesday, February 10, 2015 at 7:20:42 PM UTC-5, Lim wrote:
> Hi everyone,
>
> I was wondering if someone knows how to plot the 95% CI using the MPFIT curve fitting (http://www.physics.wisc.edu/~craigm/idl/fitting.html).
>
> In the example I can fit my model but now I need to plot the 95% CI as well as the prediction intervals.
For advanced usage I recommend using MPFITFUN instead of MPFITEXPR. Both functions return the 1-sigma standard errors with the PERROR keyword, and the covariance matrix with the COVAR keyword.
The MPPROPERR function can produce propagated confidence limits on your model function. An example is included in the documentation.
Note that 68% confidence is +/- 1 sigma, and
95% confidence is +/- 2 sigma, so just multiply the 1-sigma errors by 2.
I should also say that in my field of research, it's not simply enough to compute the parameter errors via the covariance matrix. Usually one does a parameter grid search. Numerical Recipes discusses this type of work.
Craig
|
|
|