proc (0)=drvchk(dloc,iloc,cloc,q,datfile,t,savname,qsav,&eval); local del,ndlp,ls,h,hll,dll,odll,oll,ll,ii,i,f1,y,dt,pnp,pcp,dm; local eval:proc; "DRVCHK.G: derivative checker for likelihood and derivatives coded in EVAL By John Rust, Yale University, February, 1997"; ""; format /rz,12,6; "Derivative check at parameter vector"; q'; ""; "Delta value for numerical derivatives";; del=1e-7; del; ""; "Reading "$+ftos(t,"lf",4,0)$+" observations from data file "$+datfile; ""; closeall; open f1=^datfile; dm=rows(q); i=0; ndlp=zeros(dm,1); ls=1; start: hll=zeros(dm,dm); h=hll; dll=zeros(dm,1); ll=0; ii=1; pnp=0; pcp=0; dt=readr(f1,t); {ll,dll,pnp,pcp,h,hll}= eval(dt,dloc,iloc,cloc,q,ll,dll,ls,i,pnp,pcp,h,hll); y=seekr(f1,1); if i == 0; oll=ll; odll=dll; "Initial likelihood";; oll; "Analytical gradients"; dll'; q[1,1]=q[1,1]+del; i=-1; goto start; elseif -i <= dm; ndlp[-i,1]=(ll-oll)/del; q[-i,1]=q[-i,1]-del; if -i < dm; q[-i+1,1]=q[-i+1,1]+del; i=i-1; goto start; endif; endif; "Numerical gradients"; ndlp'; "Difference"; (odll-ndlp)'; ""; "Delta : ";; del; closeall; endp;