/* EVALBLG.G: evaluation of binary logit likelihood and derivatives By John Rust, University of Wisconsin. February, 1990 */ proc (4)=evalblg(dt,dloc,iloc,cloc,q,ll,dll,ls,lle,h,hll); local y,x,p; y=dt[.,dloc]; /* dependent variable in y */ x=dt[.,iloc']; /* independent variables in x */ p=1/(1+exp(x*q)); /* set choice probabilities */ ll=ll+sumc(y.*ln(p)+(1-y).*ln(1-p)); /* cumulate log-likeihood */ dll=dll+sumc((p-y).*x); /* derivative of log-likelihood */ if ls > 0; goto skip; endif; /* don't compute hessian in linesearch */ /* if lle == -1; */ /* last likelihood evaluation iteration */ /* cumulate outer product of 1st derivs */ h=h+moment((p-y).*x,1); /* endif; */ /* cumulate hessian of likelihood */ hll=hll-moment(sqrt(p.*(1-p)).*x,1); /* ohll=ohll-((x.*p)'((1-p).*x)); cumulate hessian of log-likelihood */ skip: retp(ll,dll,h,hll); endp;