UUPharmacometrics / PsN

Perl-Speaks-NONMEM
https://uupharmacometrics.github.io/PsN
GNU General Public License v2.0
65 stars 19 forks source link

Categorical data VPC output #204

Open nitkaila opened 3 years ago

nitkaila commented 3 years ago

Hi all. I am working on an ordered categorical (DV=1,2,3) data analysis problem. I estimated PD parameters following multiple estimation approaches to estimate PK/PD simultaneously or FIX PK to estimate PD parameters. On running VPC in PsN-4.8.5
after inserting ICALL.EQ.4, $SIM with uniform random, as per the following command lines:

vpc run23_sim.mod -levels=1,2,3 -samples=20 -dir=vpc001 -lst=run23.lst -clean=3 -dv=PRLS -flip_comments vpc run23_sim.mod -levels=1,2,3 -samples=20 -dir=vpc002 -lst=run23.lst -clean=3 -dv=PRLS vpc run23_sim.mod -levels=1,2,3 -samples=20 -dir=vpc003 -lst=run23.lst -clean=3 -dv=PRLS -stratify_on=CMT

I can simulate DV as PRLS=1,2,3 after observing the 'vpc_simulation.1.npctab.dta' simulations output and the original observations in 'vpc_original.npctab.dta' files. However, on observing the vpc_results.csv file, the data is post processed as a) "Continuous data" and "Categorized data"; b) the total number of observations in both categories is the total number of PK and PD observations (CMT=2 and CMT=4); c) also some simulated PRLS values in 'vpc_simulation.1.npctab.dta' are fractions rather than 1,2,3 assigned value as per the cumulative probability and UNIFI values. As of now, it will be really helpful to post-process a corrected vpc_results.csv file to be able to display the VPC results in the xpose package, to decide on next steps for simulations and further modeling.

Screen shots as .png files attached below.

Thanks.

Nitin

data_f1 csv vpc_original lst_p1 vpc_original lst_p2 vpc_original lst_p3 vpc_original npctab dta vpc_simulation 1 npctab dta vpc_results csv

####################################### nonmem code extract

IF(ICALL.EQ.4) THEN ; .AND.NEWIND.NE.2 CALL RANDOM(2, R) UNIF1 = R PRLF = 1 IF (P1 .LT. UNIF1) PRLF=2 IF (P2 .LT. UNIF1) PRLF=3 PRLS = PRLF

IY1=0 IF(PRLF.EQ.1) IY1=1 IY2=0 IF(PRLF.EQ.2) IY2=1 IY3=0 IF(PRLF.EQ.3) IY3=1

IF(FLAG.EQ.1) THEN
Y = F*(1+EXP(EPS(1))) + EPS(2) ENDIF

IF(FLAG.EQ.2.AND.CMT.EQ.4) THEN
;F_FLAG=1 Y = IY1Y1+IY2Y2+IY3*Y3 ENDIF

IPRED = F ;IF(Y<=0)Y=1E-16 ENDIF

#######################################

rikardn commented 3 years ago

If you simulate from your model and get fractional values for DV there is a problem with the model. Run your model as a simulation model outside of the vpc first to see that your simulations are indeed what you expect. In your model snippet above: are you sure that Y will always be integer when simulating?

nitkaila commented 3 years ago

On simulating outside of vpc, DV is same as Y when, CMT=2 (PK model) as expected, and probability or fractional values bounded b/w 0 and 1 for (FLAG=2 OR CMT=4) i,e, categorical data predicted values. The PRLS assignment from ICALL.EQ.4 block of code, based from RANDOM uniform value UNIF1 and cumulative probabilities (P1, P2) are now 1,2,3 as expected; no fractions in PRLS column, as were being observed when running vpc. In the above snippet (*) are missing due to translation. Should be:

Y = IY1 Y1+IY2 Y2+IY3 * Y3

I am not sure why you write 'Y' should always be an integer when simulating. I think it should be a probability, when FLAG=2 hence a fraction, based on simulated probabilities, and 'PRLS' can take a value of 1,2,3 as in my control stream.

I will get rid of CMT=4, not needed in the control stream and dataset and use only FLAG identifier for categorical data.

Nitin

CMT=1,2_simulation_output_outside vpc

CMT=1,2_simulation_output_outside vpc

CMT=4_simulation_output_outside vpc

CMT=4_simulation_output_outside vpc

CMT=4_simulation_output_outside vpc_PRLS

CMT=4_simulation_output_outside vpc_PRLS

control_stream_extract_simulation_outside vpc

control_stream_extract_simulation_outside vpc