I've written this portion of code (see below) and it works
perfectly the problem is the execution time which is about 15
mn. Under SAS (IML) my co-author code the same thing and the
execution time is 1 (one) minute on 35900 observations. is
there a problem with my programmation Style?
AbdelRahmen
*--------begin mata code
w = st_data(., tokens(st_local("instrume"))) // matrix
q = st_data(., tokens(st_local("vprobit"))) // matrix
dmills=st_data(., "dmills") // colvector
s=st_data(., "selection") // colvector
t=st_data(., "t") // colvector
chw=cols(w) // scalar
cq=cols(q) // scalar
for (i=1; i<=nt; i++) {
jacobi=J(chw, (cq*T) ,0)
jacobi[(chw - T + t[i]),(cq*t[i] -cq
+1)..cq*t[i]]=q[i,.]:*dmills[i,.]
F=F+(s[i,.]:*h[i,.]')*beta'*jacobi
}
F=(1/n)*F
*--------end mata code
*--------begin SAS IML code
dmills=-mill1#(qpi+mill1)#q;
do i=1 to N;
jacobi=j(chw,cq#T,0);
period=t[i];
jacobi[chw-T+period,cq#(period-1)+1:cq#period]=dmills[i,];
F=F+h[i,]`*(beta`*jacobi);
F=(F/N)
*--------end SAS IIML code
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/