[R] How can I calculate the error of a fit parameter, when the data set has an error itself?
Markus Schmotz
markus.schmotz at uni-konstanz.de
Tue Mar 16 13:53:07 CET 2010
Hi out there,
imagine you have a dataset (x,y) with errors f,
so that each y_i is y_i +- f_i. This is the normal case for almost all
measurements, that one quantity y can only be measured with a certain
accuracy.
> x<-c(1,2,3)
> y<-c(1.1,0.8,1.3)
> f<-c(0.2,0.2,0.2)
> plot(x,y) #whereas every y has the uncertainty of f
If I now perform a nls-fit (and force the data through (0,0) to have
only one fitting parameter)
> n<-nls(y~a*x,start=list(a=1))
> summary(n)
I end up with an estimate of a of 1.4 +- 0.06 as standard error of the fit.
In this case the error gives only the accuracy of the fit itself, but
does not include the measurement errors in y: f (error bars).
How is it possible to take them into account? I know that there is the
chi-squared test, where the goodness of the fit is calculated, but again
this does not include the errors itself.
There should be an easy solution, since this is a common problem in
science, which I haven't found yet.
Any suggestions or solutions?
Thanks in advance!
-- Markus
More information about the R-help
mailing list