I am trying to estimate a Probit model by maximizing a log likelihood function with fminsearch. The vector of coefficients returned from fminsearch is different from what I get when I run a probit regression (using glmfit).
I did some basic debugging by printing my variables and manually checking the function against some input-output pairs. Is there something wrong with how I defined my function?
Here is my function code:
%function
function val = probit2(b,y,x)val2 = y'*log(normcdf(x*b'));val3 = (1-y)'*log(1-normcdf(x*b'));val = -1.*(sum(val2 + val3));end;
Here is my code for fminsearch:
%load data
filename = 'admit.xls';admit = xlsread(filename);y = admit(:,1);x = admit(:,2:4);%coefficients
b_true = glmfit(x,y,'binomial','link','probit');%set options
options=optimset('MaxFunEvals',2000,'MaxIter',2000);%initial guess
b0=[.001 0.464 -0.331];%fminsearch
[b,fval,exitflag,output]=fminsearch('probit2',b0,options,y,x);end;
Best Answer