老师,我是matlab基础版的学员。最近我要用fminsearch命令做回归。因为作业不准用probit命令回归,所以只好自己编程:
这个是我的m文件
function fgl=hw_probit(guess)
%generate the data
n=100;
k=1;
x=rand(n,1);
guess=0.5;
y=x*guess+normrnd(0,1,n,k);
for i=1:n,
if y(i)<0 y(i)=0;
else y(i)=1;
end;
end;
prob=normcdf(x*guess);
fgl=sum(y.*log(prob)+(1-y).*log(1-prob));
x=fminsearch('hw_probit',guess);
运行之后产生了这样的信息:
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> erf
我该如何操作呢?