I am estimating a simple probit model using fminunc as an optimization tool. The reason why I don't use other optimization strategies is because I want to change code later to estimate ordered probit. I get an error "Input to ROOTS must not contain NaN or Inf." while estimating. Could you please suggest what might be wrong with my code? (see below: w- vector of independent vars, yd-dependent dummy). Many thanks, Yevgeniya
w=M.data(:,3);yd=M.data(:,5);k=size(w,2); [b,r,stats]=regress(yd,w);start0=b; data=[w yd];f0=find(yd==0);f1=find(yd==1);opts = optimset ('Display','iter','TolX',1e-15,'TolFun',1e-15,'MaxIter',2000,'MaxFunEvals',1000000);[param,fval] = fminunc(@(start)P_Lik(data,k,indiv,f0,f1,start),start0,opts);function L = P_Lik(X,k,indiv,f0,f1,start);bcoef=start(1:k); y=X(:,end);Xb=X(:,1:k)*bcoef;w=zeros(size(X,1),1);w(f0)=log(1-normcdf(Xb(f0)));w(f1)=log(normcdf(Xb(f1)));L=-sum(w);
Best Answer