This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: Least-Squares Fitting with asymetric errors
- From: Rodney Sparapani <rsparapa at post dot its dot mcw dot edu>
- To: GSL Discuss List <gsl-discuss at sources dot redhat dot com>
- Cc: svwright+lists at amtp dot liv dot ac dot uk
- Date: Wed, 5 May 2004 16:05:14 -0500 (CDT)
- Subject: Re: Least-Squares Fitting with asymetric errors
- Reply-to: Rodney Sparapani <rsparapa at post dot its dot mcw dot edu>
>
>Hi,
>
>I was wondering if there was any advice on how to do least-squares
>fitting using GSL with asymmetric errors on my data.
>
>In the example for nonlinear least-squares fitting
> http://www.gnu.org/software/gsl/manual/gsl-ref_36.html#SEC475
>the following snippet calculates the Jacobian of the function to be
>fitted...
>
> /* Jacobian matrix J(i,j) = dfi / dxj, */
> /* where fi = (Yi - yi)/sigma[i], */
> /* Yi = A * exp(-lambda * i) + b */
> /* and the xj are the parameters (A,lambda,b) */
> double t = i;
> double s = sigma[i];
> double e = exp(-lambda * t);
> gsl_matrix_set (J, i, 0, e/s);
> gsl_matrix_set (J, i, 1, -t * A * e/s);
> gsl_matrix_set (J, i, 2, 1/s);
>
>However, this assumes that the errors (AKA standard deviation
>== sigma) is symmetric.
>
>What is the best way of allowing for asymmetric errors? Is the way to
>do it redefine my "fi" function in both the function (to fit) and the
>calculation of its derivative to be a step function?
>i.e. if ( yi <= Yi ) use the ErrorBar+ for sigma
> if ( yi > Yi ) use the ErrorBar- for sigma
>
>
>Thanks for any comments,
>
>S.
Steven:
If I understand your question correctly, it's simple: that is the least squares
criterion. You could construct some other criterion, but usually it doesn't
make much difference. The reason that you have a non-linear model is because
your errors are not mound-shaped and in this case they are not symmetric either.
Rodney Sparapani Medical College of Wisconsin
Sr. Biostatistician Patient Care & Outcomes Research
rsparapa@mcw.edu http://www.mcw.edu/pcor
Was 'Name That Tune' rigged? WWLD -- What Would Lombardi Do