help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Re: iteratively re-weighted least squares fitting


From: David Komanek
Subject: Re: [Help-gsl] Re: iteratively re-weighted least squares fitting
Date: Sun, 07 Nov 2010 22:02:16 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; cs; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6

Dear Brian,

here is the main loop:

    computeWeightsByYi(); // computes weights for the first round
    do {
        iter++;
        status = gsl_multifit_fdfsolver_iterate(s);
        if (status) break;
        status = gsl_multifit_test_delta(s->dx, s->x, 1e-4, 1e-4);
        if (movingWeights) { // boolean to switch re-weighted and
"normal" regression
            gsl_vector *params = gsl_vector_alloc(s->x->size);
            gsl_vector_memcpy(params, s->x);
            setParameters(params); // copies current model parameters
into the enclosing object member data field
            computeWeightsByFx(); // computes new weights from the new
set of parameters for the next iteration
        }
    }
    while ((status == GSL_CONTINUE) && (iter < 10000));

The solver is gsl_multifit_fdfsolver_lmsder.

The function is f(x) = a * exp(b * (x+0.5)) / (1 + a * exp(b * (x+0.5)))

With nearly certainty, the problem is on my side, but I wanted to be
sure that re-weighting is o.k. with GSL or that I will need another
approach. I am not a matematician, but I am pretty sure the partial
derivatives etc. are o.k. in my case - my colleague uses another
computing method with a success, but he has it as a set of VBA macros
in Excel and we need to do it in C/C++. For some reason I think GSL will
be better choice than blindly rewrite code lines from VBA to C++. What I
like to know is if I am using the GSL right for this type of problem.

Thank you. Kind regards,

  David

.
Dne 6.11.2010 18:46, Brian Hawkins napsal(a):
> David,
>
> What's your convergence criterion?  Is your system full-rank?  Have you had
> success with this problem using a different solver?  I'm having a hard time
> understanding why the GSL solver in particular would be giving you trouble.
>
> Regards,
> Brian
>
> On Sat, Nov 6, 2010 at 9:01 AM, <address@hidden> wrote:
>> Message: 1
>> Date: Fri, 05 Nov 2010 23:09:54 +0100
>> From: David Komanek <address@hidden>
>> Subject: [Help-gsl] iteratively re-weighted least squares fitting
>> To: address@hidden
>> Message-ID: <address@hidden>
>> Content-Type: text/plain; charset=ISO-8859-2
>>
>> Dear all,
>>
>> I ran into problems using weighted least squares fitting in GSL. For
>> some reason I need to use IRLS modification of this method, so the
>> weights are recomputed in every iteration. In the case the weights are
>> computed at the beginning and being constant throug all the iterations,
>> the procedure works fine. But when I adjust the weights in every
>> iteration, this usually leads to an error:
>>
>> 27 iteration is not making progress towards solution
>>
>> I think it is because there are some internally tested conditions and
>> some of them are not satisfied in this case. For example, in SAS, there
>> is a special parameter to relax those conditions:
>>
>>
>> http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_nlin_sect034.htm
>>
>> Is something like this possible with GSL ?
>>
>> Thank you in advance.
>>
>> David
>>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]