A timing issue in the differential equation system

Hello, Hope I am not asking too many questions. Here is one more. I want to do some user-defined calculation in differential equation system. Here is an example: calculate observed Cmax and model predicted Cmax Originally, I have some code: CC=DTA(7) IF CC>Cm_OB THEN Cm_OB=CC Cm_Mod=Z(1)/Vc ENDIF DTA(7) is the column 7, where the concentration data is. After the program reads through all the data, Cm_OB is supposed to give me observed Cmax and Cm_Mod gives me the model predicted Concentration at the same time as the observd Cmax occurs. However I found Cm_Mod was not at the same time as the Cm_OB, which is assigned by CC. I guess what happens is when CC reads a record, say at observed time 0.5 hour, the differential system has to start from zero. When Cm_OB=CC is executed, the system is still at somewhere between 0 and 0.5 hour, so Cm_Mod is the model predicted concentration sometime earlier than 0.5 hour. My question is how I can synchronize Cm_OB and Cm_Mod. Thanks. Jun

Not sure this would help. Initialize dta(3) to zero and make sire the first obs is t=0 Then use the code below and it will replace dta(3) with Cmax The final cumulative Cmax will be on the output summary table – the code below was added to PK3 from Dan Weiner’s PK/PD book Model COMM NCON 1 NPAR 3 PNAM ‘VF’,‘Tabs’,‘Ke’ NFUN 1 END TEMP T = X DOSE = CON(1) FINF = DOSE/Tabs END transform if x=0 then Cmax = y endif if x>0 and Cmax < y then Cmax = y endif dta(3)=Cmax end FUNC1 F = 0.0 IF T <= Tabs THEN F =(FINF/(KeVF))(1. - DEXP(-KeT)) ENDIF IF T > Tabs THEN F=(FINF/(KeVF))(1.-DEXP(-KeTabs))DEXP(-Ke(T-Tabs)) ENDIF END EOM ------------ end ------------ Column3 is the first column below on the summary table Cmax t Cp 0 0 0 0.0000 0.0000 0.0000 0.0000 1.0000 Missing Missing 10 0.5 10 0.5000 10.0000 20.3550 -10.3550 1.0000 1.3144 -1.8006 46 1 46 1.0000 46.0000 36.5204 9.4796 1.0000 2.0136 1.7097 56 1.5 56 1.5000 56.0000 49.3586 6.6414 1.0000 2.3729 1.2297 56 2 56 2.0000 56.0000 59.5544 -3.5544 1.0000 2.5967 -0.6711 66 3 66 3.0000 66.0000 74.0824 -8.0824 1.0000 3.1070 -1.6118 87 4 87 4.0000 87.0000 83.2454 3.7546 1.0000 3.8650 0.8425 87 5 69 5.0000 69.0000 69.3519 -0.3519 1.0000 5.2864 -0.1344 87 6 45 6.0000 45.0000 43.7414 1.2586 1.0000 3.0439 0.2491 87 7 29 7.0000 29.0000 27.5885 1.4115 1.0000 2.8880 0.2744 87 8 15 8.0000 15.0000 17.4005 -2.4005 1.0000 2.7040 -0.4579 87 9 10 9.0000 10.0000 10.9748 -0.9748 1.0000 2.3126 -0.1796 87 10 9 10.0000 9.0000 6.9220 2.0780 1.0000 1.8537 0.3711 ____________________________________________________________