Tutorials
Auto Light Dark
Auto Light Dark

Modeling the pharmacokinetics and pharmacodynamics of warfarin in healthy volunteers

Download data set only | Download all Monolix project files | Download Simulx project files | Download Simulx R scripts



Introduction and case study outline

O’Reilly (1968). Studies on coumarin anticoagulant drugs. Initiation of warfarin therapy without a loading dose. Circulation 1968, 38:169-177.

Warfarin is an anticoagulant normally used in the prevention of thrombosis and thromboembolism, the formation of blood clots in the blood vessels and their migration elsewhere in the body, respectively. The data set provides set of plasma warfarin concentrations and Prothrombin Complex Response in thirty normal subjects after a single loading dose. A single large loading dose of warfarin sodium, 1.5 mg/kg of body weight, was administered orally to all subjects. Measurements were made each 12 or 24h.

Case study outline

The case study begins with data exploration and visualization within Monolix. This exploration highlights key characteristics of the dataset, such as individual variability in plasma concentrations and the observed pharmacodynamic response over time.

In the section "Pharmacokinetic (PK) Modeling," the goal is to develop a robust PK model that accurately captures the observed data. The modeling process involves examining diagnostic plots, comparing different structural models, and refining the model using statistical tests and convergence assessments. Sycomore is employed for systematic model comparisons, enabling the selection of the most appropriate PK model.

The section "Pharmacokinetic-Pharmacodynamic (PKPD) Modeling" focuses on linking the pharmacokinetics to the observed pharmacodynamic response. Guided by visualization tools and prior knowledge, the model is developed iteratively, emphasizing the refinement of the pharmacodynamic component while maintaining consistency with the final PK model. Diagnostic tools, such as statistical tests and diagnostic plots, are used extensively to ensure the accuracy and reliability of the PKPD model.

The final section outlines the modeling workflow and demonstrates how the established PKPD model can be further validated and applied in simulations. The simulations will compare two treatment regimens by defining dosing schedules, outcome criteria, and statistical evaluation methods. Replicated simulations will be conducted to account for population parameter uncertainty, and the proportion of subjects meeting the efficacy criterion will be assessed. A statistical test will be used to evaluate statistical differences between groups, providing insights into the expected trial outcome.

Data exploration and visualization

The dataset originates from a clinical trial studying Warfarin, an anticoagulant commonly used to prevent thrombosis and thromboembolism—conditions involving the formation and migration of blood clots in the blood vessels.

Clinical trial details:

  • Participants: 32 healthy volunteers.

  • Administration type: Oral administration.

  • Dosing regimen: A single large loading dose of Warfarin sodium was administered. The dose was calculated as 1.5 mg/kg of body weight for each subject.

  • Measurement schedule: Plasma concentrations and Prothrombin Complex Activity (PCA) were measured at time intervals of 12 or 24 hours post-dosing.

Pharmacokinetic (PK) and pharmacodynamic (PD) data:

  • PK: Warfarin concentrations in plasma.

  • PD: Prothrombin Complex Activity (PCA), which reflects Warfarin's pharmacodynamic effect.

The columns in the dataset are:

  • id: The subject ID, column-type ID.

  • time: The time of the measurement or dose, column-type TIME.

  • amt: The amount of drug administered to each subject, column-type AMOUNT (1.5 mg/kg of body weight, consistent across all subjects).

  • dv: The dependent variable (measured values), column-type OBSERVATION.

    • For PK data: Plasma concentrations of Warfarin.

    • For PD data: Prothrombin Complex Activity (PCA).

  • dvid: The type of measurement:

    • DVID = 1 corresponds to PK measurements (Warfarin concentrations).

    • DVID = 2 corresponds to PD measurements (PCA).

  • wt: Subject weight (kg), column-type COVARIATE.

  • sex: Subject sex (0 = female, 1 = male), column-type COVARIATE.

  • age: Subject age (years), column-type COVARIATE.

Monolix 2024R1 Data tab with the warfarin data set loaded. Columns id, time, amt, dv, dvid, wt, sex and age are tagged as ID, TIME, AMOUNT, OBSERVATION, OBSERVATION ID, continuous covariate, categorical covariate and continuous covariate. Both observation types 1 and 2 are continuous. The table shows 511 entries for 32 individuals, with a dose of 100 at time 0 for subject 1.

Pharmacokinetic (PK) modeling

After a new project has been created, the data uploaded, and the columns correctly tagged, the observations can be visualized in the observed data plot.

It quickly becomes apparent that some profiles have no or only very sparse absorption phases. This could later impact the estimates of the absorption parameters, as there is simply less information available about the early phase of the profiles.

Monolix observed data plot of warfarin concentrations, observation 1, versus time from 0 to 120 h on a linear scale, all subjects in blue. Individual 12 is highlighted in orange and has a well sampled absorption phase, rising to a peak of about 15 near 9 h before declining to about 2 at 120 h.
Same observed data plot of warfarin concentrations versus time on a linear scale, with individual 20 highlighted in orange. Its first observation is at 24 h, so this profile has no absorption phase, only a declining elimination phase from about 9.5 to about 2.3 at 120 h.

By log-scaling the y-axis, a first impression of the elimination phase can be obtained. This allows for identifying whether it follows a linear (positive curvature) or non-linear pattern (negative curvature), and whether it can be described by a single slope or multiple linear segments. This helps determine the number of compartments to consider and choose:

Monolix observed data plot of warfarin concentrations versus time from 0 to 120 h with a log-scaled y-axis, individual profiles in blue and the geometric mean as a red line. After a peak of about 12 near 6 to 9 h, most profiles decline along a single straight slope, supporting a one-compartment model with linear elimination.

The majority of subjects exhibit a profile with a simple slope in the elimination phase, suggesting that a one-compartment model with linear elimination is a good choice for the initial structural model.

Structural PK model development

In the model library of the PK model class, various filters can be applied that relate to different phases of the time profiles. The treatment administration regime indicates that the drug was administered orally, and no delay in the absorption phase was observed in the data. First order absorption is selected, as most drugs exhibit first-order absorption. A one-compartment model seems to be a good starting point, with linear elimination and clearance (Cl) parameterization (lib:oral1_1cpt_kaVCl.txt). Finally, the choice of parameterization (ke or Cl) is not crucial, as they are equivalent.

Monolix Structural model tab, PK model library with filters selected, oral or extravascular administration, no delay, first order absorption, 1 compartment, linear elimination and clearance parametrization. The single matching model is oral1_1cpt_kaVCl with parameters ka, V and Cl, described as extravascular first order absorption with one compartment and linear elimination.

After selecting the one-compartment model, the "Initial estimates" tab is used to define initial values for the three population parameters. The auto-init function was used to automatically propose reasonable starting values. These initial values should capture the main characteristics of the profiles. This process focuses on the typical profile shape and does not account for inter-individual variability. The log scale applied to the Y-axis helps confirm that the elimination phase is well captured by the one-compartment model.

Monolix Check initial estimates tab after running Auto-init, with individual plots for ids 1 to 13 on a log y-axis showing observed warfarin concentrations as blue dots and the predicted typical profile as a red curve. Proposed values are ka_pop 0.274, V_pop 7.595 and Cl_pop 0.134, with the green Set as initial values button at the top.

The initial values are applied to the estimation tasks by clicking the green "Select as initial values" button, which redirects to the "Statistical model & tasks" tab. This tab lists the individual estimation tasks and includes the observation model, which links observations and predictions by incorporating an error term. The statistical model can be further refined in the individual model section. At this stage of modeling, the focus is on establishing a well-fitting structural model before adjusting the statistical model. Therefore, the default settings for the observation and individual models are maintained, with adjustments to be evaluated later as needed.


Monolix screenshot of the Statistical model and Tasks tab for run r01_1cmt. All tasks are selected next to the green Run button. The observation model yPK uses prediction Cc with a combined1 error model and normal distribution. In the individual model, ka, V and Cl are lognormal with random effects checked, and no correlations or covariates age, sex or wt are selected.

This model comprises a combined residual error model with both additive and proportional terms, log-normal distributions for the three parameters and along with random effects on all parameters and . Correlations between random effects and covariate effects on parameters are not included at this stage. All elements are set to their default configurations, ensuring that the tasks listed in the top panel of the "Statistical model and tasks" tab are ready to be launched.

Tasks are executed to estimate the parameters and assess the model fit to the data. Before running any tasks, it is recommended to save the project (Menu > Save as> r01_1cmt.mlxtran) to ensure that all result text files generated during the tasks are stored in a folder alongside the project file.

The “Population parameters” and “EBEs” tasks estimate both population and individual parameters. The “Conditional Distribution” task enhances diagnostic plots and the conduct of statistical tests, particularly with small sample sizes. The “Standard error” task estimates the standard error and relative standard error of the population parameters, while the “Likelihood” task calculates the objective function to identify the best population parameters. The “Plots” task is included for model diagnostics. The scenario is executed by clicking the green 'Run' button.

After running the estimation tasks, a "Results" tab becomes available, where additional plots in the "Plots" tab assist with model evaluation. Below is the results table from the "Results > Pop. param" tab.

Monolix population parameter estimates table for run r01_1cmt with S.E., R.S.E. and 95 percent bounds. Fixed effects ka_pop 0.5953, V_pop 7.81, Cl_pop 0.133. Random effect standard deviations omega_ka 0.755, omega_V 0.218, omega_Cl 0.283. Error parameters a1 0.395, b1 0.094. RSE values range from about 4.5 to 30 percent, showing good certainty.

It displays the estimates of the population parameters for fixed effects and as well as the standard deviation of the corresponding random effects (all parameters). Each parameter also has standard error estimates, relative standard error estimates, and confidence interval limits. The parameters appear to be estimated with good certainty.

In the individual fits plot in the "Plots" tab, the prediction curve based on individual parameters (here, by default EBEs) is shown alongside the observed data. It is apparent that the peaks (the highest measurements) are under-predicted for many subjects. Zooming in on the early phase (the absorption phase) for all subjects (Zoom constrain x-axis > Link zoom between plots) reveals that the first data points in profiles with early measurements are over-predicted.

Complete profile

Early absorption phase (zoomed-in)

Monolix individual fits plot for run r01_1cmt, one panel per subject, concentration y1 versus time up to about 120 hours with fitted curves and observed points. Red circles mark peak observations in subjects 3, 4, 7, 11, 12 and 13 that lie above the curve, showing the peaks are under-predicted.
Individual fits for run r01_1cmt zoomed on the early absorption phase, time 0 to about 10 hours. Red circles mark the first observations of subjects 8, 12 and 13, which lie below the fitted curves, showing that early points are over-predicted and suggesting a lag time.

The evaluation of the individual fits plot suggests that adding a lag time to the model could be beneficial. This is further confirmed by the observation vs. prediction plot. After log-log scaling the plot, the data from early time points are significantly below the identity line, indicating they are over-predicted.

Monolix observations versus individual predictions plot on log-log axes for run r01_1cmt, with the y equals x line and dashed 90 percent prediction interval. The highlighted profile of subject 2 shows its earliest point at time 0.5 far below the identity line, confirming that early observations are over-predicted.


The next modeling step should be to include lag time. This would cause the prediction curve to rise later but steeper, better capturing the early and highest measurements.

To accelerate convergence for the next model run, population estimates can be used as initial values by selecting "Use last estimates: Fixed effects" in the "All" in the "Initial estimates" tab. Then, in the "Structural model" tab, the delayed first-order absorption model (lib:oral1_1cpt_TlagkaVCl.txt) is selected by changing the filter from “no delay” to “lag time”.

Monolix Structural model tab PK library with filters oral or extravascular administration, first order absorption, 1 compartment, linear elimination and clearance. The Delay filter lag time is highlighted in red, leaving the model oral1_1cpt_TlagkaVCl with parameters Tlag, ka, V and Cl.

In the "Initial estimates" tab, an appropriate initial value for Tlag_pop should be set, typically between 0 and 1.5 based on the individual fits and observations vs predictions plot, with 0.5 being a reasonable selection. The initial values for the other five parameters remain as previously estimated.

The updated project can be saved as r02_Tlag_1cmp_Tlag.mlxtran, and the same scenario can be executed.

Population parameter estimates for the one-compartment model with lag time, run r02. Tlag_pop 0.787, ka_pop 1.46, V_pop 7.91, Cl_pop 0.133. omega_Tlag 0.679, omega_ka 1.07, omega_V 0.218, omega_Cl 0.292. Error parameters a1 0.32, b1 0.040. RSE values range from about 4 to 38 percent, and ka_pop and omega_ka increased versus run r01.

The estimates for and remain close to the previous values, while and increased. This is coherent with the model adjustments, which only affected the absorption phase. The estimates remain within a range that can be considered reliable and certain. By evaluating the diagnostic plots below, it is clear that adding a lag time was beneficial.

Individual fits - early absorption phase (zoomed-in)

Observations vs. predictions

Individual fits for the lag time model run r02, zoomed on the first 25 hours, concentration y1 versus time per subject. The fitted curves now start rising after a short delay and rise more steeply, capturing the early and peak observations better than the model without lag time.
Observations versus individual predictions on log-log axes for the lag time model run r02, with the y equals x line and 90 percent prediction interval. Points lie closer to the identity line, and the highlighted subject 2 profile, including its time 0.5 point, now follows the line much better.

Focusing on the elimination phase of the time profiles, it is visible for a few individuals, such as 6, 7, and 11, that an additional slope would better capture the final data points. This would suggest the inclusion of a second compartment. The observation vs. prediction plot also confirms that points further from the identity line correspond to later observations. However, this observation applies only to a few individuals.

Complete profile - semi log scaled

Observations vs. predictions

Individual fits for run r02 on a semi-log scale, y1 versus time up to 120 hours. Red dashed lines on subjects 6, 7 and 11 show two different slopes in the elimination phase, suggesting that a second compartment would better capture the final data points.
Observations versus individual predictions on log-log axes for run r02. The highlighted profile of subject 6 has its late point at time 96 above the prediction, far from the identity line, showing that the points furthest from the line are late observations.

The next step in model development involves the inclusion of a second compartment. Before changing the structural model, selecting "Use last estimates: All" ensures that the final estimates from the current run, which were determined with good confidence, are used as initial values for the next run. This provides a strong starting point for SAEM, aiding the convergence. The structural model is then adjusted by changing the filter in the PK model library under "Distribution" from one compartment to two compartments. Initial values for the new parameters and are determined either manually or using the auto-init function, which identifies the best overall fit. The initial values are set as follows: and . The omega parameters of the unchanged parameters retain the values from the previous run, while the omega parameters of the new ones are initialized with a value of 1. The project is saved under a new name (r03_Tlag_2cmt.mlxtran), and the scenario is executed.

In the results tab for population parameters, the estimation of shows very high uncertainty, affecting both the fixed effect and the standard deviation of the random effect . This indicates that the parameter is difficult to estimate, which aligns with observations from the diagnostic plots. Only a few individuals exhibit characteristics of a second compartment, resulting in limited contributions to the SAEM algorithm for reliably estimating parameters related to the second compartment.

Population parameter estimates for the two-compartment model with lag time, run r03_Tlag_2cmt. Most parameters have moderate RSE, but Q_pop at about 0.75 has an RSE of about 1560 percent and omega_Q about 1.33 has an RSE of 141 percent, both highlighted, showing that Q is very poorly estimated.

The plots overall demonstrate a good fit.

To enable a quantitative comparison between models during the model development process, the Monolix project can be exported to Sycomore. This is done via the export menu: Export > Export project to ... > Target software: Sycomore. Sycomore facilitates the calculation and visualization of metrics such as BICc, qnd -2LL, allowing for a robust comparison of model performance.

Sycomore Hierarchy tab comparing runs r01_1cmt, r02_Tlag_1cmt and r03_Tlag_2cmt. Importance sampling -2LL is 831.36, 671.67 and 649.95, and BICc is 869.3, 718.59 and 714.82. Adding the lag time greatly improves the fit, while the second compartment lowers -2LL but improves BICc only slightly.

What can be stated with certainty is that the inclusion of a lag time in the absorption profile led to a significantly improved fit. The difference in -2LL and BICc between run 2 (r02_Tlag_1cmt.mlxtran) and run 1 (r01_1cmt.mlxtran) amounts to and .
The likelihood estimate also improved in the two-compartment model (r03_Tlag_2cmt.mlxtran) compared to the one-compartment model (r02_Tlag_1cmt.mlxtran), reflecting a better fit to the data. However, the BICc did not improve in the same magnitude, indicating that the increase in model complexity might not be justified statistically.

Assessment of parameter estimate robustness

To assess the stability of parameter estimates, the convergence assessment was performed by running the scenario five times with different seeds and slightly varied initial values. For the two-compartment model (r03_Tlag_2cmt.mlxtran), the parameter and likelihood estimates showed significant variability across runs, indicating unstable convergence. In contrast, the one-compartment model (r02_Tlag_1cmp.mlxtran) demonstrated stable and consistent estimates.

1-compartment model with Tlag (r02_Tlag_1cmp.mlxtran)

2-compartment model with Tlag (r03_Tlag_2cmt.mlxtran)

Monolix convergence assessment for the one-compartment lag time model r02, SAEM trajectories of five runs with different seeds for each population parameter. V_pop, Cl_pop, omega_V, omega_Cl, a1 and b1 converge to the same values, while Tlag_pop, ka_pop and omega_ka end at somewhat different levels.
Convergence assessment for the two-compartment model r03_Tlag_2cmt, SAEM trajectories of five runs. Besides Tlag_pop, ka_pop and omega_ka, the second-compartment parameters V1_pop, Q_pop, V2_pop, omega_V1, omega_Q and omega_V2 end at clearly different values, showing unstable estimates.
Convergence assessment plot of -2LL by importance sampling for the five runs of the one-compartment lag time model r02. All values lie between about 671.5 and 672.3, showing consistent likelihood estimates across runs.
Convergence assessment plot of -2LL by importance sampling for the five runs of the two-compartment model r03. Values spread from about 647 to 662, showing unstable likelihood estimates across runs.

In the convergence assessment, the trajectories for ​ and in both runs diverge, likely due to some subjects lacking measurements in the absorption phase. While all subjects have measurements in the elimination phase, the SAEM trajectories for parameters related to the second compartment in run r03_Tlag_2cmt.mlxtran also show divergence. This is because only a few subjects display characteristics of a second compartment in their profiles. As a result, the estimates in r03_Tlag_2cmt.mlxtran are less stable and more uncertain, which is also reflected in the high uncertainty of the parameter. Overall, model r02_Tlag_1cmp.mlxtran provides a good fit while ensuring more robust and reliable parameter estimates, making it the preferred final structural model.

Statistical PK model development

Adjustment to the residual error model

Model development begins by evaluating the structural model to ensure it captures the key profile characteristics, followed by selecting the best error model to account for prediction-observation deviations.

The selection of the residual error model is guided by the Results tab "Proposal," where different error models (constant, proportional, combined1, combined2) are evaluated. The criterion is calculated for each error model, with the error parameters optimized based on the data and the predictions generated by the final structural model.

Current residual error model: combined 1

Prefered residual error model: combined 2

The combined2 error model appears to fit the data better than the combined1 error model. Unlike combined1, which assumes a linear relationship between error and prediction, combined2 accounts for nonlinearity by modeling the total error as the square root of the sum of squared constant and proportional terms.

The next step is to switch to the combined2 error model. The final estimates from r02_Tlag_1cmt.mlxtran are used as initial values, the project is saved under a new name (r02_1_Tlag_1cmt_comberr2.mlxtran), and the estimation tasks are launched. The error parameters and remain in the same range as the previous estimates but show lower RSE values. Additionally, the information criteria indicate that switching to the combined2 error model has improved the model fit.

r02_Tlag_1cmp.mlxtran - combined 1

r02_1_Tlag_1cmt_comberr2.mlxtran - combined 2

Monolix table of error model parameters for run r02_Tlag_1cmt with combined1 error model. a1 0.3215 with RSE 13.5 percent and b1 0.04032 with RSE 18.2 percent.
Monolix information criteria for run r02_Tlag_1cmt with combined1 error model. -2LL or OFV 671.67, AIC 691.67, BIC 706.33 and BICc 718.59.
Monolix table of error model parameters for run r02_1_Tlag_1cmt_comberr2 with combined2 error model. a1 0.3446 with RSE 11.4 percent and b1 0.07069 with RSE 10.2 percent, lower RSE values than with combined1.
Monolix information criteria for run r02_1_Tlag_1cmt_comberr2 with combined2 error model. -2LL or OFV 662.30, AIC 682.30, BIC 696.96 and BICc 709.22, all lower than with combined1, so the fit improved.

Covariate model

After establishing the base model, the next step is to incorporate covariate effects that influence the distribution of individual parameters. If these effects are not included, their contribution to variability remains within the variability of the random effects.

The dataset contains only a few covariates, allowing for a manual forward inclusion and backward elimination approach to develop the covariate model. Each model run includes the conditional distribution and plots tasks, generating statistical tests and diagnostic plots to identify influential effects.

In the "Test" section of the Results tab, the random effect shows the strongest covariate effects. The lowest p-value is from the correlation test between body weight (wt) and , assessing whether the correlation coefficient differs significantly from zero.

The second-lowest p-value comes from the ANOVA Type III test, which evaluates the effect of sex on . A significant p-value in this test indicates that the variance in is significantly different between the two sex modalities. This suggests that the mean values of for males and females are significantly distinct, and the variability in is not the same for both groups.

Monolix covariate test table for the random effect eta_V. The sex ANOVA has statistic 18.73 and p-value 1.539e-4, age is not significant with p-value 0.81, and wt has correlation coefficient 0.743 and p-value 1.09e-6. The sex and wt p-values are highlighted in red as significant.

The "Individual Parameters vs Covariates" plot confirms these findings. The scatterplot of vs. wt shows a steep regression line, while the boxplots of grouped by sex modality reveal a clear separation in both mean and spread.

Monolix Individual parameters versus covariates plot showing random effects eta_V. Left, eta_V versus wt with a steep regression line and correlation 0.71. Right, boxplots of eta_V by sex, with sex 0 centered around -0.3 and sex 1 around 0.05 with a wider spread, showing a clear separation.

In the “Observed data” plot, coloring profiles by weight shows that subjects with higher body weight tend to have higher concentrations, even though the drug was administered weight-normalized. Coloring by sex shows that male subjects tend to have higher concentrations than female subjects.

Observed data plot - colored by weight

Observed data plot - colored by sex

Monolix Observed data plot of concentration y1 versus time up to 120 hours, profiles colored by weight group, wt 40 to 73.3 in orange and wt 73.3 to 102 in green. Heavier subjects tend to have higher concentrations, including the highest peaks around 17.
Monolix Observed data plot of concentration y1 versus time up to 120 hours, profiles colored by sex, sex 0 in red and sex 1 in blue. Subjects with sex 1 tend to have higher concentrations and include all the highest peaks, while sex 0 profiles are lower.

In the manual forward inclusion and backward elimination approach, the strongest effect is first considered, which in this case is body weight wt on volume . The covariate is included via a power law relationship. To transition from the lognormal domain to the gaussian domain, the covariate must be log-transformed.

log-normal domain

Gaussian domain

In Monolix, selecting a continuous covariate in the individual model prompts a suggested log transformation (“Add log-transformed“), creating a new column where the covariate is logarithmized and normalized by a typical population value.

Monolix Statistical model and Tasks tab for run r02_2_Tlag_1cmt_comb2err_logwtV with the Edit logtWt dialog open. The formula is log of wt divided by 68.1178, with min -0.53, mean 0.010, median 0.050 and max 0.40. In the individual model, logtWt is checked for parameter V.

The new covariate logWt is added to the individual model for parameter . The last estimates are used as initial values, the project is saved under a new name (r02_2_Tlag_1cmt_comb2err_logwtV.mlxtran), and the estimation task is launched.

The new population parameter ​ appears in the population parameter table as a fixed effect, estimated with good certainty.

Forward inclusion

Backward elimination

Correlation test/ ANOVA

Wald test

Correlation test

Covariate test table for eta_V after adding logtWt on V. None of the covariates is significant anymore, with p-values sex 0.38, age 0.65, logtWt 0.83 and wt 0.83.
Wald test table for beta_V_logtWt, value 0.8955, statistic 6.45 and p-value 1.09e-10, showing the weight effect on V is significantly different from zero.


Correlation test table for backward elimination of beta_V_logtWt, statistic 7.61 and p-value 1.75e-8, showing the effect is significant and should remain in the model.


Statistical tests show that wt and logWt no longer have significant p-values for ​, confirming their relevance in the forward inclusion step.

For backward elimination, additional tests are performed:

  • Correlation test: Assesses if the regression coefficient between covariates and transformed parameters differs from zero.

  • Wald test: Evaluates whether the estimated is significantly different from zero, using standard errors.

Both tests yield significant p-values, indicating that the effect is considered relevant and should remain in the model. Additionally, the inclusion of wt corrected the previously observed sex effect, indicating that the sex difference was likely due to wt-related variability distortions in .

In the plot “Individual parameters vs. covariates“ the accounted weight effect visibly corrected the distribution of ​, reducing distortion. The scatter plot of vs. wt now shows a less pronounced trend, and the boxplots grouped by sex reveal a reduced difference in mean and spread. The previously observed sex effect disappears when accounting for weight, likely because heavier subjects in the population are generally male, while lighter subjects are more often female. In other words, weight and sex were correlated.

Individual parameters versus covariates plot after adding logtWt on V. Left, eta_V versus wt now has an almost flat regression line with correlation 0.036. Right, boxplots of eta_V by sex 0 and 1 now overlap, with only a small difference in median and spread, so the sex effect has largely disappeared.

Comparing information criteria of the current model run (r02_2_Tlag_1cmt_comb2err_logwtV.mlxtran) with the previous model without covariate effects (r02_1_Tlag_1cmt_comberr2.mlxtran) shows a likelihood difference of and a BICc difference of , confirming that capturing and explaining variability with WT was beneficial.

The stepwise forward inclusion and backward elimination of covariates continues until no significant effects remain.

The final model includes a weight effect (logtWt) on and , and an age effect (logtAge) on , leading to the lowest information criteria and . However, this model slightly inflates the RSE of . Backward elimination tests show borderline p-values, just below 0.05. Comparing the run with only logtWt on and (r02_3_Tlag_1cmt_comb2err_logwtVCl.mlxtran) to the final model with logtWt on and & logtAge on (r02_4_Tlag_1cmt_comb2err_logwtVCl_logageCl.mlxtran) shows a difference and , indicating only a minor improvement in variability explanation.

No significant correlations between random effects were detected, concluding the PK model development.

Pharmacokinetic - Pharmacodynamic (PKPD) modeling

The next step is to describe the effect of warfarin on blood clotting. This is done by looking at prothrombin complex activity (PCA), which measures how well certain clotting factors in the blood are working.

Examining PKPD data

The PCA values range from 0 to 100. The spaghetti plot shows PCA starting at 100 at time 0, decreasing, and then gradually increasing again. PCA declines as PK concentrations rise, but not simultaneously—the lowest PCA values do not coincide with the highest PK values, indicating a delay.

The bivariate plot confirms this pattern. With PK data on the x-axis and PD data on the y-axis, PD values remain relatively constant at first as PK increases. Then, a rapid drop occurs, forming a downward-curving loop. This behavior clearly rules out a direct PK-PD relationship.

Observed data plot

Bivariate data viewer

Monolix observed data plot of the PD observations, PCA labeled 2, versus time from 0 to about 144 hours, spaghetti lines for all subjects with arithmetic mean in red and subject 14 highlighted in orange. PCA starts at 100, drops to about 10 to 30 near 48 hours, then rises again, showing a delayed response relative to the PK concentrations.
Monolix bivariate data viewer plot with PK concentration y1 on the x-axis, 0 to about 18, and PCA labeled 2 on the y-axis. Arrows show the time direction, subject 14 in orange. PCA stays near 90 to 100 as concentrations rise, then drops sharply, forming a downward-curving loop that rules out a direct PK-PD relationship.

These PKPD relationship characteristics suggest two possible models, both describing how warfarin inhibits prothrombin complex activity (PCA): an effect compartment model or a turnover model.

Structural PD model development

For modeling PD data, PK parameters should not be re-estimated, as reliable estimates are already available. In the “Initial Estimates” tab, selecting “Use last estimates: All” applies the previously estimated PK values. To keep them fixed, “Fix parameter values: All” is selected below.

In the “Structural Model” tab, the PKPD model class retains the filter for the PK model, requiring only the selection of the appropriate PD model. The turnover model is chosen with production inhibition as the drug action filter, specifically partial inhibition, since PCA values do not drop to zero. Sigmoidicity is also selected, introducing the variable , which adds flexibility by allowing a sigmoidal response curve. If is estimated close to 1, the model can still be simplified.

Monolix Structural model tab, PKPD library selected and highlighted. Filters chosen are oral administration, lag time, first order absorption, 1 compartment, linear elimination, clearance, plus turnover response, production inhibition, partial inhibition and with sigmoidicity. One model matches, with parameters Tlag, ka, V, Cl, R0, gamma, kout, Imax, IC50.

The prediction vector is mapped to observation id dvid= 2 in the panel next to the structural model.

Mapping panel next to the structural model. Data observation ID 1 is linked to model output y1, prediction Cc, and observation ID 2 is linked to y2, prediction R, the PCA response.

In the “Initial estimates” tab, the parameter is set to 100 and fixed, as it corresponds to the baseline value of the PCA time profiles, with all subjects starting at 100. This ensures that , like the PK parameters, remains unchanged during the estimation tasks.

In the “Check initial estimates“ subtab the correct output radio button must first be selected to display the PD plots - in this case. Then the auto-init function is applied to find initial population parameters that best fit the data points for the PD data, while the PK parameters and , which appear in orange.

Monolix Check initial estimates subtab for r02_4_1_turnover with output y2 selected. Individual PCA fits for 12 subjects show red model curves over blue data points. Below, PK values and R0_pop equals 100 appear in orange as fixed, while auto-init proposes gamma_pop about 0.71, kout_pop about 0.075, Imax_pop about 0.79 and IC50_pop about 0.13.

In the “Statistical model & task” tab, below the observation model , the PD observation model is now also displayed. It retains the default settings for the error model and distribution assumption.

Since PCA values range between 0 and 100 and follow therefore a logit-normal distribution, the distribution setting must be adjusted accordingly. To define the boundaries, the lower limit is set to 0, and the upper limit to 100.1, ensuring that 100 is included, as all subjects start from a baseline of 100. Additionally, the error model for the PD observations needs to be changed from the default combined1 to constant, as it is better suited for the logit-normal distribution of the PCA measurements

Observation model table in the Statistical model and tasks tab. Observation ID 1, y1, prediction Cc uses a combined2 error model with a normal distribution. Observation ID 2, y2, prediction R uses a constant error model with a logitnormal distribution and limits 0 to 100.1.

By default, all parameter distributions are set to lognormal, except for , which is logit-normal, as its values range between 0 and 1. Monolix applies this setting automatically when recognizing standard parameter names from the library. If an uncommon parameter name is used, Monolix defaults to a lognormal distribution. In such cases, the distribution must be adjusted before initializing estimates, as auto-init selects values based on the predefined distribution range.

Since the parameter corresponds to the baseline value of the PD data and is the same for all subjects, inter-individual variability is not considered. The random effect can therefore be removed.

Individual model table with the PD parameters gamma, R0, kout, Imax and IC50 outlined in red. All use lognormal distributions except Imax, which is logitnormal. Random effects are checked for every parameter except R0. Covariate effects logtWt on V, and logtAge and logtWt on Cl, remain from the PK model.

No further model adjustments are required. The project can be saved under a new name (r02_4_1_turnover.mlxtran).

The turnover model has now been fully set up, covering all necessary steps from model selection to parameter initialization and error model adjustments. Another potential approach for describing the PKPD relationship is the effect compartment model. While structurally different, its implementation follows the exact same steps as the turnover model, with only differences in parameter names.

Turnover model

Effect compartment model

Monolix population parameter estimates table for the turnover model. gamma_pop about 1.54, R0_pop fixed at 100, kout_pop about 0.061, Imax_pop about 0.92, IC50_pop about 1.07, with random effect standard deviations omega_gamma 0.28, omega_kout 0.20, omega_Imax 0.57, omega_IC50 0.52, and error parameter a2 about 0.19. All RSEs are below about 28 percent.
Monolix population parameter estimates table for the effect compartment model. ke0_pop about 0.017, gamma_pop about 2.48, E0_pop fixed at 100, Imax_pop about 0.9996, IC50_pop about 2.52, with omega_ke0 0.27, omega_gamma 0.24, omega_Imax about 3.09, omega_IC50 0.24, and a2 about 0.21. All RSEs are below about 28 percent.
Information criteria table for the turnover model. -2 times log-likelihood, OFV, about 1771.0, AIC about 1789.0, BIC about 1802.2, BICc about 1815.7, lower than for the effect compartment model.
Information criteria table for the effect compartment model. -2 times log-likelihood, OFV, about 1812.8, AIC about 1830.8, BIC about 1844.0, BICc about 1857.5, clearly higher than for the turnover model.
Monolix VPC plot of PCA y2 versus time for the turnover model, with blue and pink prediction intervals and empirical percentile lines. The empirical 10th, 50th and 90th percentiles mostly stay within the theoretical prediction intervals, with only small red outlier areas between about 24 and 120 hours.
Monolix VPC plot of PCA y2 versus time for the effect compartment model. Large red outlier areas show the outer empirical percentiles, 10th and 90th, falling outside the prediction intervals during the PCA decline, from about 20 to 80 hours, indicating misspecification of the delayed effect.

Both models yield similarly well-estimated population parameters with relatively good certainty. However, the effect compartment model has significantly higher BICc and -2LL compared to the turnover model. The VPC plot also indicates clear model misspecification in the effect compartment model, as the outer empirical percentiles (10th and 90th) systematically fall outside the theoretical percentiles during the decline of PCA. This suggests a misrepresentation of the delayed effect. In contrast, the VPC plot of the turnover model shows that the empirical percentiles mostly remain within the theoretical percentiles throughout the time profile.

Based on the evaluation of results and diagnostic plots, the turnover model better captures the PCA data and is selected as the final model.

Assessment of parameter estimate robustness

At this stage, it is necessary to verify whether the final model also produces stable estimates by performing a convergence assessment, as done previously during the development of the PK model. Five runs are conducted with different initial values and different seeds. If the estimates are robust, the five final parameter estimates should be closely aligned, along with the log-likelihood values.

Convergence assessment (r02_4_1_turnover.mlxtran)

SAEM - Trajectories

-2LL


Convergence assessment of the turnover model r02_4_1_turnover, SAEM trajectories for five runs in different colors. gamma_pop, kout_pop, Imax_pop, IC50_pop, the omegas and a2 converge to similar values, but omega_Imax fluctuates strongly upward, reaching about 1.2, which may be related to simulated annealing.


Convergence assessment of r02_4_1_turnover, -2LL by importance sampling for runs 1 to 5. Values vary from about 1772 for run 5 to about 1787 for run 2, a spread of about 15, showing unstable likelihood.


The turnover model (r02_4_1_turnover.mlxtran) shows varying likelihood values ( ). The trajectories indicate that fluctuates significantly upwards, which may be related to simulated annealing.

Note: Simulated annealing is enabled by default in Monolix to facilitate a broader exploration of the parameter space during the SAEM algorithm's exploration phase. By gradually decreasing the variance of random effects and residual error, it helps to increase the chances of finding a global optimum. However, this approach can also lead to upward fluctuations in the standard deviations of the random effects ( ).

In the next step, the simulated annealing option in the population parameter estimation task is disabled, the auto-stop criterion is turned off, and the number of iterations in the exploration phase is increased from 500 to 1000. Extending the exploration phase allows more time to refine parameter estimates and prevents premature stopping, which can occur if convergence is detected too early, especially in complex models or noisy data. This ensures a more thorough exploration of the parameter space, leading to potentially more stable estimates.

Monolix Statistical model and tasks tab of r02_4_2_turnover_nosimann with the settings dialog for population parameter estimation open via its wrench icon. In the exploratory phase, the auto stop criteria toggle is off, number of iterations is set to 1000, and simulated annealing is disabled, all highlighted in red.

The project is saved under a new name (r02_4_2_turnover_nosimann.mlxtran) without carrying over the estimated values, ensuring that the initial values remain the same as in the previous run (r02_4_1_turnover.mlxtran). The estimation tasks and convergence assessment are then performed to evaluate the impact of the modified settings.

Turnover model without simulated annealing (r02_4_2_turnover_nosimann.mlxtran)

Tunover model with simulated annealing (r02_4_1_turnover.mlxtran)

Population parameter estimates for the turnover model without simulated annealing, r02_4_2_turnover_nosimann. gamma_pop about 1.43, R0_pop 100, kout_pop about 0.061, Imax_pop about 0.92, IC50_pop about 1.00, omega_gamma 0.29, omega_kout 0.18, omega_Imax 0.58 with RSE 45 percent, omega_IC50 0.52, and a2 about 0.20.
Population parameter estimates for the turnover model with simulated annealing, r02_4_1_turnover, for comparison. gamma_pop about 1.54, R0_pop 100, kout_pop about 0.061, Imax_pop about 0.92, IC50_pop about 1.07, omega_gamma 0.28, omega_kout 0.20, omega_Imax 0.57 with RSE about 28 percent, omega_IC50 0.52, and a2 about 0.19.
SAEM trajectories of omega_Imax for five convergence assessment runs of the turnover model without simulated annealing. Runs extend to about 1100 iterations and oscillate mostly between about 0.3 and 0.8, settling near 0.4 to 0.55, smoother than with simulated annealing.
SAEM trajectories of omega_Imax for five convergence assessment runs of the turnover model with simulated annealing. Runs stop between about 300 and 570 iterations and show high upward oscillations, peaking near 1.2, before ending between about 0.45 and 0.65.
-2LL by importance sampling for five convergence runs of the turnover model without simulated annealing. Values range from about 1780 to 1784, a maximum difference of about 4, indicating stable likelihood.
-2LL by importance sampling for five convergence runs of the turnover model with simulated annealing. Values range from about 1772 to 1787, a much larger spread than without simulated annealing.

A comparison of the two models shows that the PD population parameter estimates are very similar, with relatively good certainty. The omega parameters do not become very small, and their RSEs increase, indicating that the random effects remain identifiable after disabling simulated annealing and that parameter variability should be retained. Disabling simulated annealing also reduces high oscillations in the trajectories of , leading to a smoother and more extended convergence, which results in a more stable likelihood. The model without simulated annealing leads to 4. No further improvements in stability are observed, making this the final PKPD model.

Simulations

The final Monolix model serves as a basis for simulations. The transition from estimations to simulations is seamless, facilitated by exporting the Monolix project to Simulx, where all estimates and the model are directly transferred.

Using this model, different treatment regimens can be simulated. The objective is to assess whether the proportion of subjects with PCA below 35% of baseline at 96 hours is significantly higher in the test arm, which receives 20 mg once daily for two days followed by 10 mg once daily, compared to the reference arm receiving 10 mg once daily. Each arm includes 100 individuals in a parallel trial design.

The new treatment regimens are specified in the “Definition” tab under the “Treatment” subtag. The group receiving the loading dose is labeled Group_withLoading, while the group receiving a consistent daily drug amount is labeled Group_noLoading. The following treatment elements are defined.

Group_withLoading

Group_noLoading

Simulx treatment element 20mg_loading_for2days, defined in manual mode, highlighted. Administration 1, with two doses of amount 20 at times 0 and 24, also highlighted.
Simulx treatment element 10mg_maintenance_OD in regular mode, highlighted. Start time 48, interdose interval 24, 12 doses, amount 10, for the Group_withLoading arm.
Simulx treatment element 10mg_OD in regular mode, highlighted, for the Group_noLoading arm. Start time 0, interdose interval 24, 14 doses, amount 10.


For the simulation, a new output vector is defined, extending well beyond 96 hours after the first administration. It is based on the prediction curve (prediction of PCA), starting at time 0 and ending at 336 hours. The time discretization grid is set to hours. This allows visualization of the output distribution curve over time, capturing multiple administrations and providing the PCA value at 96 hours.

Simulx output element R_reg defined in regular mode, highlighted. Output variable R, the PCA prediction, with start time 0, interval 3 and final time 336 hours.

The simulation scenario is defined as follows. The parameter element is set to the vector , which contains all population parameter estimates. The newly defined output vector , extending to 336 hours, is selected. Treatment definitions differentiate the groups: the group receiving the loading dose (Group_withLoading) includes the elements , representing 20 mg administrations at 0 and 24 hours, and , covering 10 mg administrations from 48 to 312 hours. The second group (Group_noLoading) receives only 10 mg administrations from 0 to 312 hours. Each group consists of 100 individuals. Since the simulated population exceeds the original study population size, the element is used to generate individual weight and age values while maintaining the same overall distribution.

Simulx Simulation tab with single simulation selected. Shared settings are group size 100, parameters mlx_Pop, output R_Reg and covariates mlx_CovDist. Group_withLoading receives 20mg_loading_for2days and 10mg_maintenance_OD, while Group_noLoading receives 10mg_OD.

The Simulx project is saved under a new name (s01_simulation.smlx), and the simulation is conducted.

The output distribution plot displays the 5th, 50th, and 95th percentiles of the simulated data for all IDs. Visual cues at the time point of 96 hours (x=96h) and response level of 35% (y=35) show that both simulation groups have a median response below 35% at 96 hours. However, a substantial part of the percentile bands remains above this efficacy limit. The group receiving the loading dose reaches and stays below this threshold faster than the group without a loading dose.

Simulx output distribution plots of R, predicted PCA, versus time to about 336 hours, side by side for Group_noLoading in red and Group_withLoading in purple, showing median and 5th to 95th percentile bands. Reference lines at 96 hours and R equals 35 show both medians below 35 at 96 hours, about 30 versus 24, with much of the bands above.
Simulx output distribution plot overlaying both groups, R versus time to about 336 hours. Medians and 5th to 95th percentile bands for Group_noLoading in red and Group_withLoading in purple. The loading dose group reaches and stays below the line at 35 faster, with medians about 30 and 24 at the 96 hour line.


The qualitative assessment suggests that the group with the loading doses performs better than the group without it. However, a quantitative comparison is required to confirm this observation. To achieve this, the simulation is post-processed by defining an outcome variable and summarizing it as an endpoint. The simulation groups can then be compared based on this endpoint.

The outcome is defined in the “Outcome & Endpoint” panel of the “Simulations” tab, representing a single value per subject. It is based on the prediction output vector . Custom value per ID is selected for output processing to extract the prediction at 96 hours. Additionally, a threshold is set to identify subjects with a predicted response below 35%, generating a boolean outcome: True for PCA values below 35% and False otherwise.

Simulx outcome definition PCAinTarget, based on output R_Reg, relative to none, output processing at a custom point per id at time 96, with apply threshold checked for values less than 35.

Once the outcome is created, an endpoint is automatically generated, summarizing the percentage of subjects in each simulation group for whom the result is True. Enabling the group comparison toggle allows for a statistical evaluation of differences between groups.

Simulx 2024R1 screenshot of the Simulation tab for project s02_OutcomeEndpoint, Outcomes and endpoints panel. Outcome PCAinTarget and endpoint1 Percent true are set. Highlighted in red are the Group comparison toggle switched on with Statistical test selected, the alternative hypothesis H1 oddsRatio greater than 1, and Reference group Group_noLoading. The p-value threshold is 0.05.

The statistical test applied is an odds ratio test using Fisher’s exact test. The objective is to determine whether the proportion of patients with PCA < 35% of baseline at 96 hours is significantly higher in the arm with the loading dose. The Group_noLoading arm is set as the reference group. The null hypothesis states that the reference group performs equally or better, implying a ratio 1, while the alternative hypothesis tests whether the Group_withLoading performs better, leading to an odds ratio > 1.

Null hypothesis

Alternative hypothesis

where and is the percentage of subject of their corresponding simulation group for which the condition holds true.

If the p-value is below 0.05, the null hypothesis is rejected in favor of the alternative hypothesis , indicating a successful trial.

The project is saved under a new name (s02_OutcomeEndpoint.slmx), and the outcome and endpoint task can be performed without rerunning the simulations, as the scenario remains unchanged.

In the plots section, an outcome distribution plot is generated, displaying bar charts for each treatment group. These charts visually represent the number of subjects meeting the efficacy criteria versus those who do not.

Simulx outcome distribution plot with one bar chart per treatment group, y-axis Number of individuals, bars colored by PCAinTarget true or false. Group_noLoading has 64 true and 36 false subjects, Group_withLoading has 75 true and 25 false, so more subjects meet the PCA below 35 percent criterion with the loading dose.

The results tab under the endpoint subtab shows the percentage of true outcomes per treatment group, with 75% in the Group_withLoading and 64% in the Group_noLoading. The group comparison subtab presents the results of the statistical odds ratio test. The difference between Group_withLoading and Group_noLoading is not statistically significant, though the p-value is borderline.

Odds per group

Group comparison

Simulx endpoint results tables, odds per group. Group_withLoading has percentTrue 75 and totalTrue 75, Group_noLoading has percentTrue 64 and totalTrue 64.


Simulx group comparison table for Group_withLoading versus the reference, replicate 1. Odds ratio 1.69, p-value 6.21e-2, and success marked with a cross, so the difference is not statistically significant, although the p-value is borderline.


The smooth predictions based on ​ already indicate no clear significant difference between the treatment groups, suggesting that the expected population-level effect is minimal or absent. Given this outcome, further simulations incorporating noise through the response output vector​ and accounting for parameter uncertainty may not drastically alter the overall conclusion.

However, introducing variability could still provide insight into how much random fluctuations influence the results, particularly in equally sized or smaller sample sizes. If the goal is to evaluate whether the observed trend holds under realistic conditions, replicated simulations could be valuable. On the other hand, if the smooth model already offers a reliable estimate and the expected effect size is small, the additional complexity may not yield further insights.

The simulation scenario requires some modifications. First, a new output vector must be created based on the observed PCA measurements. In the “Definition” tab under the output subtab, the observation vector , which consists of model predictions with an error model, replaces the smooth prediction vector as the basis. This time, only the 96-hour time point is of interest.

Simulx output element dialog named PCA_at96h_withNoise. The output variable is y2, the observation with residual error, and the Times field contains only 96, so the noisy PCA observation is simulated at 96 hours.

Next, the simulation scenario is set to replicates, with 20 experiment repetitions. The parameter element mlx_PopUncertain is selected, ensuring that the 20 simulations use different sets of population parameters to account for parameter uncertainty. Individual parameters in each replicate are drawn from these varying population parameters. The newly defined vector is selected as the output element.

Simulx simulation scenario screenshot. Highlighted in red are Replicates set to 20, the shared Parameters element mlx_PopUncertainSA and the Outputs element PCA_at96h_withNoise. Group size is 100, covariates use mlx_CovDist. Group_withLoading gets 20mg_loaging_for2days and 10mg_maintenance_OD treatments, Group_noLoading gets 10mg_OD.

Finally, in the outcome & endpoint panel, the vector used for outcome calculations must be updated accordingly. The project is then saved under a new name (s03_ClinicalTrialReps.smlx), and simulations along with outcome and endpoint calculations are performed.

A new plot has been generated, summarizing the subjects who met the efficacy criterion across all replicates. Overall, Group_withLoading shows a higher median than Group_noLoading.

Simulx box plot of endpoint1, the percent of subjects meeting the efficacy criterion, distribution over 20 replicates. Group_withLoading has a median about 74 with range about 61 to 85, Group_noLoading a median about 58 with range about 44 to 69, so the loading dose arm shows a higher median.

In the “Results” tab, the “Group Comparison” subtab presents a table with the statistical evaluation of the 20 comparisons. The "Summary" section displays the power of the clinical trial. Repeating the trial 20 times, incorporating noisy PCA measurements and population parameter uncertainty, results in a success rate of 80%.

Group comparison of 20 replicates

Success rate over all 20 replicates

Simulx group comparison table for the 20 replicates, first page showing replicates 1 to 10 with odds ratio, p-value and success for Group_withLoading. Odds ratios range from about 1.14 to 2.63. Replicates 1, 2, 3 and 6 fail, the others succeed with p-values below 0.01.
Simulx summary table of the group comparison over all 20 replicates. For endpoint1, Group_withLoading has a success rate of 80 percent, with a 95 percent confidence interval from 58.4 to 91.93, which is the estimated power of the trial.

Simulations using lixoftConnectors

All steps for setting up and executing the simulation scenario can be scripted one-to-one using the lixoftConnectors in R. The exact same approach is used as in the Simulx GUI.

First, a Monolix project is either exported or imported, followed by the definition of different treatment arms via the connector defineTreatmentElement():

  • Group with loading dose: 20 mg at time 0 and 24 h (2 doses) & 10 mg from 48 h to 312 h with an interdose interval of 24 h (12 doses).

  • Group without loading dose: 10 mg from time 0 to 312 h with an interdose interval of 24 h (14 doses).

Next, the output vector is defined by defineOutputElement() based on the smooth predictions of the response vector , extending to 336 h with an equidistant time discretization of 3 h.

R
rm(list = ls())
path.prog <- suppressWarnings(dirname(rstudioapi::getSourceEditorContext()$path))
setwd(path.prog)

# GOAL: Simulate treatment scenarios in Simulx to assess outcomes across different treatment groups

path.software <- paste0("C:/Program Files/Lixoft/MonolixSuite2024R1") 
install.packages(paste0(path.software,"/connectors/lixoftConnectors.tar.gz"), repos = NULL, type="source", INSTALL_opts ="--no-multiarch")
library(lixoftConnectors)

# software initialization: specify the software to be used
initializeLixoftConnectors(path.software,software = "monolix")

# loading the final Monolix project
path.project <- paste0(path.prog,"/r02_4_2_turnover_nosimann.mlxtran")
loadProject(projectFile = path.project)

# export monolix project to simulx
exportProject(settings = list(targetSoftware = "simulx", filesNextToProject = T), force=T)

# definition of the new treatment regimen
defineTreatmentElement(name = "20mg_loading_for2days", element = list(data=data.frame(start=0 , interval=24, nbDoses=2 , amount=20)))
defineTreatmentElement(name = "10mg_maintenance_OD"  , element = list(data=data.frame(start=48, interval=24, nbDoses=12, amount=10)))
defineTreatmentElement(name = "10mg_OD"              , element = list(data=data.frame(start=0 , interval=24, nbDoses=14, amount=10)))

# definition of the output vector
defineOutputElement(name = "R_Reg", element = list(data = data.frame(start = 0, interval = 3, final = 336), output = "R"))

The simulation scenario is then specified with setGroupElement(), incorporating the two treatment groups with different dosing regimens while maintaining the same group size, parameter element mlx_Pop, output vector R_Reg, and covariate element mlx_CovDist.

The outcome and endpoint are defined via the connectors defineOutcome() & defineEndpoint() before running the simulation. The outcome for each subject is determined based on whether the criterion PCA(96h) < 35% is met. If satisfied, the subject is assigned true; otherwise, false. The results are then summarized using the endpoint and statistically compared. An odds ratio test (Fisher’s exact test) is applied, using Simulation Group 2 as the reference. The goal is to assess whether simulationGroup1 meets the efficacy criterion significantly more often.

R
# simulation scenario setup
setGroupElement(group = "simulationGroup1", elements = c("mlx_Pop"))
setGroupElement(group = "simulationGroup1", elements = c("R_Reg"))
setGroupElement(group = "simulationGroup1", elements = c("mlx_CovDist"))
setGroupElement(group = "simulationGroup1", elements = c("20mg_loading_for2days","10mg_maintenance_OD"))
setGroupSize("simulationGroup1",100)
addGroup("simulationGroup2")
setGroupElement(group = "simulationGroup2", elements = c("10mg_OD"))

# outcome definition
defineOutcome(name = "PCAinTarget", element = list(output = "R_Reg", processing = list(operator = "timePoint", value =96),applyThreshold = list(operator = "<", threshold = 35))) 

# endpoint definition 
defineEndpoint(name    = "TreatmentComparison_OR_test", 
               element = list(outcome         = "PCAinTarget",  
                              metric          = "percentTrue",
                              groupComparison = list(type      = "statisticalTest", 
                                                     operator  = ">", 
                                                     threshold = "1", 
                                                     pvalue    = 0.05)))
# set reference group
setGroupComparisonSettings(referenceGroup = "simulationGroup2", enable = TRUE)

# configure simulation and endpoint calculation
setScenario(c(simulation = T, endpoints = T))
runScenario()

The simulation results can be retrieved via getSimulationResults() and written as a data frame. A few lines of code create the output distribution plot, but calculating the percentiles of the simulated response curves requires loading the dplyr package. Diagnostic plots can be constructed using ggplot. The last line is optional and splits the simulation group plots; commenting it out merges the split plots.

R
# retrieve simulation results
sim_results <- data.frame(getSimulationResults()$res$R)

library(dplyr)
# Compute percentiles
summary_data <- sim_results %>%
  group_by(time, group) %>%
  summarise(p5  = quantile(R, 0.05), # 5th percentile
            p50 = quantile(R, 0.50), # Median
            p95 = quantile(R, 0.95), # 95th percentile
            .groups = "drop")

library(ggplot2)
# create output distribution plot distinct by simulation groups
output_distrib <- ggplot(summary_data, aes(x = time, group = group, fill = group)) +
  geom_ribbon(aes(ymin = p5, ymax = p95, fill = group), alpha = 0.3) +
  geom_line(aes(y = p50, color = group), linewidth = 0.7) +
  geom_vline(xintercept = 96, color = "#FF0000", linetype = "solid", linewidth = 0.8) + # vertical line at 96h
  geom_hline(yintercept = 35, color = "#FF0000", linetype = "solid", linewidth = 0.8) + # horizontal line at 35% response
  scale_color_manual(values = c("simulationGroup1" = "#4D1BCA", "simulationGroup2" = "#E3173E")) +
  scale_fill_manual(values = c("simulationGroup1" = "#4D1BCA", "simulationGroup2" = "#E3173E")) +
  labs(x = "Time", y = "R", title = "Output distribution") +
  theme_minimal() +
  theme(legend.title = element_blank(), legend.position = "bottom") 
  # facet_wrap(~group)
R ggplot output distribution plot created with lixoftConnectors, split into simulationGroup1 with loading dose and simulationGroup2 without. Median R and 5th to 95th percentile bands versus Time up to about 336 h. Red reference lines mark 96 h and R equals 35. Both medians fall from 100 to about 24 and are below 35 at 96 h, group 1 falls faster.
R ggplot output distribution plot with both simulation groups overlaid, purple simulationGroup1 with loading dose and pink simulationGroup2 without. Median R and 5th to 95th percentile bands versus Time, with red lines at 96 h and R equals 35. Group 1 drops below 35 earlier, both medians settle near 24.

The outcome and endpoint results can also be retrieved as a data frame by getEndpointsResults(). The following code summarizes the outcome results using a stack chart, which visualizes the endpoint results.

R
# retrieve outcome and endpoint results
res_PCAinTarget    <- data.frame(getEndpointsResults()$outcomes$PCAinTarget)
res_Endpoint       <- data.frame(getEndpointsResults()$endpoints$TreatmentComparison_OR_test)
res_TrtmComparison <- data.frame(getEndpointsResults()$groupComparison$TreatmentComparison_OR_test)

# Calculate the count of TRUE and FALSE for each simulation group
summary_data <- res_PCAinTarget %>%
  group_by(group) %>%
  summarise(TRUE_count  = sum(PCAinTarget == TRUE),
            FALSE_count = sum(PCAinTarget == FALSE),
            total       = n()) %>%
  tidyr::pivot_longer(cols      = c(TRUE_count, FALSE_count), 
                      names_to  = "outcome", 
                      values_to = "count") %>%
  mutate(outcome    = ifelse(outcome == "TRUE_count", "TRUE", "FALSE"),
         percentage = count / total * 100)

# Create the stacked bar chart
outcome_distrib <- ggplot(summary_data, aes(x = group, y = count, fill = outcome)) +
  geom_bar(stat = "identity", position = "stack") +
  geom_text(aes(label = paste0(count, " (", round(percentage, 1), "%)")), 
            position = position_stack(vjust = 0.5)) +
  labs(title = "PCA Outcome by simulation group", x = "", y = "", fill = "Outcome modalities") +
  theme_minimal() +
  scale_fill_manual(values = c("TRUE" = "#4CAF50", "FALSE" = "#F44336"))
R ggplot stacked bar chart titled PCA Outcome by simulation group. simulationGroup1 has 75 TRUE, 75 percent, and 25 FALSE, 25 percent. simulationGroup2 has 64 TRUE, 64 percent, and 36 FALSE, 36 percent. Green bars are TRUE, red bars FALSE.

The final step involved simulating a clinical trial and repeating the experiment 20 times. This introduced more noise into the response and accounted for population parameter uncertainty. The definition of treatment arms remains unchanged, but the output vector and therefore also the outcome need to be redefined.

R
# definition of the output vector
defineOutputElement(name = "PCA_at96h_withNoise", element = list(data = data.frame(time=96), output = "y2"))

The simulation scenario must incorporate the parameter element mlx_PopUncertainSA and the new output vector PCA_at96h_withNoise, while all other settings remain the same.

R
# simulation scenario setup
setGroupElement(group = "simulationGroup1", elements = c("mlx_PopUncertainSA"))
setGroupElement(group = "simulationGroup1", elements = c("PCA_at96h_withNoise" ))
setGroupElement(group = "simulationGroup1", elements = c("mlx_CovDist"))
setGroupElement(group = "simulationGroup1", elements = c("20mg_loading_for2days","10mg_maintenance_OD"))
setGroupSize("simulationGroup1",100)
addGroup("simulationGroup2")
setGroupElement(group = "simulationGroup2", elements = c("10mg_OD"))

# outcome definition
defineOutcome(name = "PCAinTarget", element = list(output = "PCA_at96h_withNoise", processing = list(operator = "none"), applyThreshold = list(operator = "<", threshold = 35))) 

The number of repetitions must be explicitly specified with setNbReplicates().

Once these adjustments are made, the simulations can be executed.

R
# retrieve outcome and endpoint results
res_Endpoint <- data.frame(getEndpointsResults()$endpoints$TreatmentComparison_OR_test)

# Create boxplots
boxplots <- ggplot(res_Endpoint, aes(x = group, y = percentTrue, fill = group)) +
  geom_boxplot()+
  scale_fill_manual(values = c("simulationGroup1" = "#E3173E", "simulationGroup2" = "#4D1BCA")) +
  labs(title = "Distribution of % true endpoints across replicates", x = "", y = "") +
  theme_minimal() +
  theme(legend.position = "none")
R ggplot box plot titled Distribution of percent true endpoints across replicates. simulationGroup1, with loading dose, has a median about 74 and range about 61 to 85. simulationGroup2 has a median about 58 and range about 44 to 69.

Discussions and conclusions

The model development process required several steps to ensure not only a good model fit but also stable and robust estimates. The convergence assessment proved valuable in verifying whether seemingly reliable estimates were truly reproducible.

Simulations indicated that the treatment group with a loading dose showed no statistically significant effect compared to the schedule without a loading dose. The applied test compared the odds of meeting the efficacy criterion PCA(96h) < 35%, with a borderline p-value suggesting a possible trend.

Although the initial experiment, based on smooth prediction response curves and stable estimates, showed no significant treatment group difference, simulating a clinical trial with added noise and uncertainty and repeating it multiple times provided further insights. The conclusion is that in 80% of repetitions, the loading dose treatment arm was statistically significantly superior to the treatment arm without a loading dose based on the efficacy criterion.

Last updated: