Filter löschen
Filter löschen

Matrix is singular, RCOND=NAN

37 Ansichten (letzte 30 Tage)
dav
dav am 17 Mär. 2013
I am using the following code in a simulation and get a warning message. Is there any way to correct it?
lb = 0.00001*ones(2,1);
ub = 0.99998*ones(2,1);
options =optimset('Display','off','LargeScale','off');
coef = lsqlin(bC,by,[],[],[],[], lb ,ub ,[],options);
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. > In qpsub at 359 In lsqlin at 336 In seasonalarch1 at 330
Thanks

Akzeptierte Antwort

Matt J
Matt J am 17 Mär. 2013
Bearbeitet: Matt J am 17 Mär. 2013
You are constructing C and y inadequately. You do not have enough linear equations, or they are not linearly independent enough, to uniquely identify the actual coef. Find additional and more informative equations and add them as new rows to C and y until cond(C) improves.
  32 Kommentare
dav
dav am 23 Mär. 2013
ok thanks..
one last question,
in an earlier comment you had asked why I said that the correct value is 0.2.
I said it because the data set we used for that lsqlin code was generated such that the ar coeff was 0.2.
If lsqlin works properly shouldn't it give values closer to 0.2 rather than very small values which course all these issues?
Thank you very much for you time, answers and comments!!!!
Matt J
Matt J am 23 Mär. 2013
Bearbeitet: Matt J am 23 Mär. 2013
How close it will be to your simulated value depends on how much noise you have in your observation data.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Youssef  Khmou
Youssef Khmou am 17 Mär. 2013
hi,
The determinant of the matrix bC is close to zero, you have to alter bC .
  3 Kommentare
Walter Roberson
Walter Roberson am 17 Mär. 2013
How did you create bC ? There might not be a way to avoid the problem for that set of data.
dav
dav am 17 Mär. 2013
Bearbeitet: dav am 17 Mär. 2013
I have a Time series data set (1000).
I took all the data corresponding to "day one" to one vector, day two to another vector and so on.. then I use lsqlin to estimate the parameters. However, the parameter estimates sometime are VERY CLOSE TO ZERO, but the actual parameters aren't that close to zero. this is why I am getting this warning.
Is there any way to correct it please?
CODE:
clc;
clear;
%warning off;
runs =100;
xxtt=[];
bxxtt=[];
p=1;
yt1=[];
yt2=[];
yt3=[];
yt4=[];
yt5=[];
xt1=[];
xt2=[];
xt3=[];
xt4=[];
xt5=[];
epsi=zeros(3000,1);
simsig=zeros(3000,1);
a0(1)=0.5; a1(1)=0.2;
for i=2:4
a0(i)=0.1; a1(i)=0.3;
end
a0(5)=0.1;a1(5)=0.2;
for i = 1:3000
m = mod(i,5);
if m==0
m=5;
end
if (i==1)
simsig(i) = a0(m)/(1-a1(m));
s=(simsig(i))^0.5;
epsi(i) = normrnd(0,1) * s;
else
simsig(i) = a0(m)+ a1(m)*(epsi(i-1))^2;
s=(simsig(i))^0.5;
epsi(i) = normrnd(0,1) * s;
end
end
epsi2=epsi.^2;
yt = epsi2(2001:3000);
ytinitial = epsi2(2001:3000);
sig = simsig(2001:3000);
ytlast=epsi(3000)^2;
ytlast2=epsi(2999)^2;
s=1;
for i=1:1000
m = mod(i,5);
if m==0
m=5;
end
if m==1
yt1(s) = yt(i);
if i==1
xt1(s)=0.00001;
else
xt1(s) = yt(i-1);
end
elseif m ==2
yt2(s) = yt(i);
xt2(s) = yt(i-1);
elseif m==3
yt3(s)= yt(i);
xt3(s) = yt(i-1);
elseif m==4
yt4(s)= yt(i);
xt4 (s)= yt(i-1);
elseif m==5
yt5(s)= yt(i);
xt5(s)= yt(i-1);
end
s=s+1;
end
yt1(yt1==0) = [];
yt2(yt2==0) = [];
yt3(yt3==0) = [];
yt4(yt4==0) = [];
yt5(yt5==0) = [];
xt1(xt1==0) = [];
xt2(xt2==0) = [];
xt3(xt3==0) = [];
xt4(xt4==0) = [];
xt5(xt5==0) = [];
yt1=yt1';
yt2=yt2';
yt3=yt3';
yt4=yt4';
yt5=yt5';
xt1 = xt1';
xt2 = xt2';
xt3 = xt3';
xt4 = xt4';
xt5 = xt5';
ytt = [ yt1, yt2, yt3, yt4, yt5];
xtt = [ xt1, xt2, xt3, xt4, xt5];
%xxtt=[xxtt;xtt];
for m = 1:5
y = ytt(:,m);
x= xtt(:,m);
len = length(y);
C = zeros(len,p);
C(:,1) = 1; % The first column is for a0
%for i = 1:p %Then we create shifted columns ( p in number ) for a
% C(1+i:len,1+i) = x(1:len-i,1);
%end
C = [C x];
lb = [0.00001 0.00001]';
ub = [0.99998 0.99998]';
options =optimset('Display','off','LargeScale','off');
coef = lsqlin(C,y,[],[],[],[], lb ,ub,[],options);
alpha0(m) = coef(1);
ar1(m) = coef(2);
end

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by