Documentation

3.6 Simulate and plan: sims and power

A fitted model is also a generator. Two commands use it that way. sims simulates a study from a model and summarises the exposure; power asks how many subjects a study needs to detect an effect. Both are quick on the demo project, with one exception that is worth seeing.

3.6.1 sims: simulate the study, summarise the exposure

nlmx sims models/run101.ctl -o out_sims

With no options, sims takes the parameters in the control stream, generates a dataset of 100 subjects that follows the regimen of the model's dosing, simulates from the model and computes the exposure of the last dosing interval at steady state. It takes a third of a second.

   0.01s ok    100 subjects in 1 arm(s), 1200 observations
   0.03s info  steady state: the trough of the analysed interval is within 0.01 % of the one before it in all 100 checked intervals
nlmx sims — models/run101.ctl
  Parameters    initial estimates of the control stream
  Dataset       generated: 100 subjects, 1200 observations in 1 arm
  Simulation    seed 20260101, 1 simulation; ETA sample, EPS sample
  Metrics       interval last (tau 24 h); profile dense; AUC linear-up-log-down

  metric              N       MEAN         SD     CV_PCT    GEOMEAN     MEDIAN         P5        P95
  CMAX              100      2.506     0.7272      29.02      2.405      2.375      1.505        3.9
  AUCTAU            100      34.65      16.05      46.33      31.28       30.7      13.53      64.27

The program states what it did and why. The line "the control stream has no $SIMULATION record" tells you that the seed (20260101) and the single simulation are defaults; the line about steady state says that 20 doses were given and that the interval analysed has settled (the trough changes by less than 0.01 % from one interval to the next). The result is a mean peak of 2.5 mg/L and a mean AUC over the dosing interval of 34.7 mg·h/L, with the spread that the between-subject variability of the model gives. These come from the base model, simulated from its initial estimates, for a generated population: the generated dataset has no covariate values (EGFR and CRCL are written as 0, as the notes say). To simulate the subjects of a real dataset, with their covariates, give sims the dataset with --data data/analysis.csv and a model that uses them (run102); Chapter 28 shows this and the other options (arms, dose levels, several simulations, parameter uncertainty).

3.6.2 power: how many subjects?

Before a study, or before a covariate claim goes into a label, the question is how large the study must be to see an effect. power answers it for a model parameter (here: weight on clearance, with the exponent 0.75 of the allometric tradition) in two ways.

nlmx power models/run101.ctl --sample-sizes 40,80,120,160 --test "CL~WT=0.75" --plots -o out_power_fim

The default method is FIM, the Fisher information matrix: from the design (the sampling of the dataset) the program computes the expected standard error of every parameter, and from it the power of a Wald test of the effect. It needs no simulation and takes 0.1 s:

FIM (fo linearisation, reduced matrix, 0.1 s)
  [1] N=40    largest expected RSE 164.6 % (THETA(5))   WT on CL   power 0.769 (Wald); 44 subjects for 0.8
  [2] N=80    largest expected RSE 116.4 % (THETA(5))   WT on CL   power 0.968 (Wald); 44 subjects for 0.8
  [3] N=120   largest expected RSE  95.0 % (THETA(5))   WT on CL   power 0.997 (Wald); 44 subjects for 0.8
  [4] N=160   largest expected RSE  82.3 % (THETA(5))   WT on CL   power 1.000 (Wald); 44 subjects for 0.8
Power of the Wald test of the weight effect on clearance against the number of subjects, with the 0.8 target
Figure 3.6.1. The power curve of the weight effect on CL (FIM): power against the number of subjects, with the target of 0.8.

Figure 3.6.1 reads: the curve crosses 0.8 at about 44 subjects, so with this design (ten samples per subject) a weight effect of 0.75 is detected with 80 % power by about 44 subjects, and almost surely by 120. The "largest expected RSE" in the listing is the expected relative standard error of the least precise parameter of the model, here THETA(5), the additive residual error. It is a property of the design, not of the weight effect, and the two should not be confused.

The second method, SSE (stochastic simulation and estimation), is the one that does not rest on an approximation: it simulates many datasets from the model, fits each, tests the effect by a likelihood-ratio test and counts the rejections. That is a fit per replicate, and the time shows it:

nlmx power models/run101.ctl --method sse --sample-sizes 60,120 --test "CL~WT=0.75" --replicates 20 --seed 12345 -o out_power_sse
SSE (20 replicate(s) per scenario, lrt test, 77 s)
  [1] N=60    converged 100.0 %   WT on CL   power 0.900 (95 % CI 0.699–0.972, n 20)  meets the target
  [2] N=120   converged 100.0 %   WT on CL   power 1.000 (95 % CI 0.839–1.000, n 20)  meets the target

Forty fits took 77 s on two cores. Twenty replicates are a demonstration, not an analysis: the confidence interval of the power at N = 60 runs from 0.70 to 0.97. A real planning study uses hundreds or thousands of replicates (and --threads), and reports the interval. The two methods agree here on the message: 60 subjects are enough, with a margin. Chapters 30 and 31 treat both methods, the other tests, and the choice between them.

3.6.3 What you have, and what you do not

You now have a model, its covariates, a check against the data, an exposure summary and a sample-size estimate. What you do not have is a claim of validity beyond the data: the data were simulated, and a real project adds the documentation, the review and the decisions of Part VIII.