I have used R a lot in the past, but never for simulation. I have a code in SAS for the Graded Response Model (GRM), also known as Samejima's model. This code simulates an ordinal response, provided item characteristics (A=item discrimination, BB(G) are thresholds between various categorical responses). It is a macro file. I am thinking that I can write this as a function, and call it up inside a simulation code. Here is the SAS code: %MACRO GRGEN; DO G=1 TO NCAT-1; Z=EXP(A*(THETA-BB(G))); PS(G)=Z/(1+Z); END; PP(1)=1-PS(1); PP(NCAT)=PS(NCAT-1); DO G=2 TO NCAT-1; PP(G)=PS(G-1)-PS(G); END; X=RANUNI(-1); SUMP=0; R(J)=1; DO K=1 TO NCAT-1; SUMP=SUMP+PP(K); IF X>SUMP THEN R(J)=K+1; END; %MEND GRGEN; Now, I am totally unfamiliar to simulation in R. So does anyone have a good reference I could go to convert this? Or have any suggestions for how to convert it to R? My biggest problem is all the loops inside this program. In particular, how to setup the updating of R(J). It seems if I built a function for this, I need the item parameters A and BB's (possibly the NCAT). Any suggestions? Thanks for any help or info. Keith Yang University of Tennessee --------------------------------- [[alternative HTML version deleted]]