Simulating crossover trials
Introduction
This tutorial describes how to simulate a two-period crossover clinical trial in Simulx using a model that was originally developed and estimated on a parallel-design Monolix project.
Because the original Monolix model comes from a parallel trial, it does not contain occasion structures, sequence covariates, or crossover-specific design information. However, these components can all be created directly in Simulx. By defining occasions, treatments, and covariates representing the different sequences (e.g., RT and TR), you can simulate a crossover trial without modifying the underlying model and without introducing inter-occasion variability (IOV).
This tutorial walks through the necessary steps to transform a parallel-trial model export into a valid 2x2 crossover simulation setup in Simulx — including adding occasions, defining sequences, configuring group-specific covariates, and generating simulated crossover data.
1. Export the Monolix Model to Simulx
In Monolix, open your project.
Go to Export → Export Project To… → Simulx.
Check all covariates in the “Include unused covariates” dropdown.
This allows you to define sequence-specific covariates later even if they weren’t used in parameter estimation.Click Export and open the generated Simulx project.
2. Create Occasions
Crossover trials require two occasions: Period 1 and Period 2.
In Simulx, go to Definition → Occasions.
Click on the “+” button and select Manual.
Add two occasions:
Occasion 1 start: 0
Occasion 2 start:
If there is a washout: set Occasion 2 start = washout duration
If there is no washout: use the cumulative time (e.g., first dose time of Period 2)
Save the occasion structure.
Since we assume no IOV, these occasions will not drive variability—only timing.
3. Create the Treatment Element
The treatment element defines the dosing regimens for each occasion.
Go to Definition → Treatments.
Add a new treatment by clicking on the “+” button.
Use occasion-wise values.
Define doses for both occasions (if the treatments have different doses, you will need to create two elements—one for each sequence).
Save the element.
4. Create the Output Element (Sampling Times)
Define how observations are recorded.
Go to Definition → Outputs.
Add a new output element by clicking on the “+” button.
If both occasions start with time 0, and have the same output times, there is no need to use occasion-wise values.
Add sampling times and choose the output variable with residual error (e.g., CONC).
Save the element.
5. Create Covariates for the Sequences (RT, TR)
To model a 2×2 crossover (RT/TR or AB/BA), create covariate elements that define the sequence assignment.
Example:
Sequence RT:
Occ 1 → “R”, Occ 2 → “T”Sequence TR:
Occ 1 → “T”, Occ 2 → “R”
Steps:
Go to Definition → Covariates.
Create a covariate element (e.g., seq_RT):
Occasion 1: value = 1 (R)
Occasion 2: value = 2 (T)
Create a second element (e.g., seq_TR) with reversed values.
Save both.
6. Set Up Simulation Groups
Each sequence will be simulated as a separate group.
Go to the Simulation tab.
Create:
Group 1: Sequence RT
Group 2: Sequence TR
For each group:
Under Shared, select:
Treatment element (except if doses are treatment-specific)
Output element
Under Covariates, assign:
Group 1 → seq_RT
Group 2 → seq_TR
Adjust group sizes to match your planned sample sizes (e.g., 20 subjects each).
7. Run the Simulation
Go to the Simulation tab.
Confirm:
Occasions defined correctly
Covariates differ across groups
Treatments and outputs are shared
Click Run.
You will obtain simulated individual time-courses for both sequences.
8. (Optional) Add IOV
If you want to introduce inter-occasion variability (IOV) into the crossover simulation, the easiest way is to do it via Monolix (to avoid coding statistical model in Simulx).
8.1 Export the Simulx Project to Monolix
In Simulx, export the current project to Monolix.
8.2 Enable IOV in the Statistical Model
Go to Statistical model & Tasks.
For the parameters on which you want to include IOV (typically absorption-related parameters, such as ka, lag time, or F):
Check Random effects on the occasion level.
Keep the individual-level random effects unchanged unless required.
8.3 Export Back to Simulx (Without Running Monolix)
Export the Monolix project back to Simulx.
Do not run Monolix after enabling IOV.
The purpose of this export is only to update the model structure to include occasion-level random effects.
8.4 Recreate the Simulx Design Elements
Because exporting from Monolix overwrites the Simulx design:
Recreate all Simulx elements from Steps 2 to 6:
Occasions (you can overwrite the external occasion structure that is automatically created)
Treatment element
Output element
Sequence-specific covariate elements (RT, TR)
Simulation groups and group sizes
8.5 Recreate the mlx_Pop Element
From the previous Simulx project (without IOV), copy or recreate the
mlx_Popelement.Ensure it uses the updated Monolix model that now includes occasion-level random effects.
Tip: This guarantees consistency in population parameters while allowing the new IOV structure to drive between-period variability.
8.6 Run the Simulation
Run the simulation in Simulx.
The simulated data will now include:
Between-subject variability (BSV)
Inter-occasion variability (IOV) across crossover periods
9. (Optional) Export Simulated Data to PKanalix
If you want a BE (bioequivalence)-style workflow:
Go to Export → Export Project To… → PKanalix.
In the Data tab, click on the Add. covariates dropdown and select Covariate sequence.
In Bioequivalence design section in Tasks → NCA, select covariateSequence as the sequence factor.
Perform NCA and BE calculations.
The whole process can be automated using lixoftConnectors. Example can be found in the following video, starting from 2:54.
https://youtu.be/W6mqDqR64Xw?list=PLNV-B2kQEx8BgMngq3FJZ5S9ZrdAZp3Pt