Simulation using fminunc: how to move to a next repetition when fminunc gives the following mistake "Input to ROOTS must not contain NaN or Inf"
1 view (last 30 days)
Show older comments
[EDIT: 20110721 12:40 CDT - reformat - WDR]
Hi, I'm new to Matlab. I am trying to do simulation of ordered probit with 100 repetitions (reps=100) (see below). At some point I get a bad draw in the error when creating ystar, and the "fminunc" stops with the following error "Input to ROOTS must not contain NaN or Inf". How can I ignore this error and move on to the next repetition?
Many thanks, Yevgeniya
while i<=reps;
ystar= FEind*betaind+FEtime*betatime+X*beta+randn(n,1);
y=zeros(n,1);
f0=find(ystar<=0);
f1=find(ystar>0 & ystar<=c1);
f2=find(ystar>c1 & ystar<=c2);
f3=find(ystar>c2 & ystar<=c3);
f4=find(ystar>c3);
y(f0)=1; %simulate categories
y(f1)=2;
y(f2)=3;
y(f3)=4;
y(f4)=5;
clear f0 f1 f2 f3 f4;
start0=[1 1 ones(t+indiv-2,1)' 1 2 3 ]';
data=[X FEtime FEind];
n=length(y); %# of observations
f1=find(y==1);
f2=find(y==2);
f3=find(y==3);
f4=find(y==4);
f5=find(y==5);
opts = optimset ('Display','iter','TolX',1e-15,'TolFun',1e-15,'MaxIter',2000,'MaxFunEvals',1000000);
[param,fval] = fminunc(@(start)OP_LikPan(data,f1,f2,f3,f4,f5,k,t,indiv,start),start0,opts);
param_rep(i,:)=param';
i=i+1;
end;
0 Comments
Answers (0)
See Also
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!