help-octave
[Top][All Lists]
Advanced

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

Re: OT: finding the weights used in weighted least squares regression


From: Ben Abbott
Subject: Re: OT: finding the weights used in weighted least squares regression
Date: Wed, 27 Apr 2011 12:49:30 -0400

On Apr 27, 2011, at 10:11 AM, Kamaraju S Kusumanchi wrote:

> Ben Abbott wrote:
> 
>> Ok. I see my mistake now. Essentially you want to solve for W where ...
>> 
>> diag (W) * (A * x - b) = c
>> 
>> But you don't know "c". However, you do know that "c" are the least square
>> errors.
>> 
>> I don't see a direct solution. Would an iterative solution work?
> 
> Yes, an iteration solution is also fine.
> 
>> I don't know how stable it would be but, is something like below
>> acceptable?
>> 
>> err = @(u) x - (diag (u) * A) \ (diag (u) * b);
>> W = fsolve (err, ones (n, 1))
>> 
> 
> This gives me an error
> 
> octave:11> err = @(u) x - (diag (u) * A) \ (diag (u) * b);
> octave:12> W = fsolve (err, ones (n, 1))
> error: fsolve: unable to solve non-square systems
> error: fsolve: evaluation of user-supplied function failed
> error: evaluating assignment expression near line 12, column 3
> 
> 
> The documentation of fsolve (help fsolve), does not clearly tell how to 
> specify the FCN argument. Could you please help me out with the error?
> 
> thanks

This example works for me with Octave 3.4. I assume one of the recent 
changesets is responsible. You can try to use sqp.

        err = @(u) norm (x - (diag (u) * A) \ (diag (u) * b));
        W = sqp (ones (n, 1), err)

The result looks unstable to me.

Ben



reply via email to

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