help-octave
[Top][All Lists]

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

 From: Kamaraju S Kusumanchi Subject: Re: OT: finding the weights used in weighted least squares regression Date: Wed, 27 Apr 2011 01:19:44 -0400 User-agent: KNode/4.4.7

```Ben Abbott wrote:
>
> If I understand what you'd like to do, I think the solution is ...
>
> W = (A*(A\b)-b) ./ (A*x-b)
>

No. This is not the solution. Consider the following example

octave:10> n=5, m=2, W = diag(rand(n,1)), A = rand(n,m), b = rand(n,1), x =
(W*A) \ (W*b), (A*(A\b)-b) ./ (A*x-b)
n =  5
m =  2
W =

0.63718   0.00000   0.00000   0.00000   0.00000
0.00000   0.75466   0.00000   0.00000   0.00000
0.00000   0.00000   0.69982   0.00000   0.00000
0.00000   0.00000   0.00000   0.08992   0.00000
0.00000   0.00000   0.00000   0.00000   0.94621

A =

0.833095   0.568790
0.792483   0.536521
0.702069   0.588282
0.036704   0.529085
0.238762   0.427252

b =

0.86356
0.77943
0.77652
0.98000
0.49344

x =

0.32941
0.97441

ans =

2.07510
-7.79993
2.55568
0.23533
112.87186

Hence W is not same as (A*(A\b)-b) ./ (A*x-b) .

thanks
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/

```