[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: leasqr problem - covp is 'NA'!!!

**From**: |
Przemek Klosowski |

**Subject**: |
Re: leasqr problem - covp is 'NA'!!! |

**Date**: |
Mon, 18 Apr 2011 14:22:11 -0400 |

**User-agent**: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 |

On 04/15/2011 12:09 PM, neo7891 wrote:

hey guys,
I'm try to solve exponential fitting with leasqr.
The fitting itself is really good - and I want to measure the estimation
error of parameters.

...

but the problem is... my 'covp' is only...
========================================
covp =
NA NA NA NA

...

data = load("data2.txt");

`so , covariance matrix is invalid, and we don't know why. It probably
``has to do with what particular data you're using, so we'd need your
``data2.txt. It could also be a bug in the leasqr() implementation so
``you'd need to specify which version of Octave you're using.
`

`I tried my Octave 3.2.4, using synthetic data that should match your
``function:
`
x=[0:.1:3]'; y=1-exp(-x)+0.1*(rand(length(x),1)-1); pin=[0,1,1,0];
[f,p,kvg,iter,corp,covp,covr,stdresid,Z,r2] = leasqr(x,y,pin,F);
plot(x, y, "r+", x, f, "b-");
p
and got reasonable fit, p=0.061542 0.915680 0.931379 0.104827

`The covariance matrix results in sqrt(diag(covp))) values of 77.468751
`` 77.468741 0.061083 90.835584. These values look strange, given
``the goodness of the fit; I haven't dwelved into it but the covp matrix
``looks strange--- approximately
`
1000 * [1 -1 0 1; -1 1 0 -1; 0 0 0 0; 1 -1 0 1]

`which doesn't make sense to me but I haven't thought about it long
``enough to convince myself one way or the other. Practitioners of leasqr,
``what do you think about the reliability of covp values?
`

x = data(1:length(data),1);
y = data(1:length(data),2);
orgFx = @(x, p) p(1) + p(2) * ( 1 - exp( -p(3) * ( x - p(4))));
pin = ones(1,4);
pin(1) = median(y(1:5));
pin(2) = max(y) - min(y);
pin(3) = abs(log(max(y) - min(y))) / (max(x)-min(x));
pin(4) = min(x);
F = orgFx;
[f,p,kvg,iter,corp,covp,covr,stdresid,Z,r2] = leasqr(x,y,pin,F);
plot(x, y, "r+", x, f, "b-");
fprintf("%f %f %f %f\n", p(1), p(2), p(3), p(4));