# pscDesign

#### Richard Jackson

#### 2026-01-23

# pscDesign: A tool for Synthetically Controlled Trials

pscDesign is a package which allows the design of prospective studies/trials using Personalised Synthetic Controls.

The purpose of a fully synthetic trial is to recruit only patients to an experimental arm. Personalised synthetic controls here allow a patients observed response to be compared against their model estimated control. Details can be found here (“https://richjjackson.github.io/mecPortal/”).

We present an example based in Pancreatic Ductal Adenocarcinoma using a Counter Factual Model (CFM) generated on patients receivign Gemcitabine therapy. Full details on the model setting, construction, validation and interpretation are found here

## Trial Design

The overall design uses a Bayesian approach and uses a simulation study to estimate the study parameters. Evaluations of efficacy are based on the posterior distribution comparing the experimental regimen against the synthetically generated controls.

Trial design also dependes on the ability to recruit patients, in this example we assume a study with 4 sites recruiting at an average rate of 0.88 patients/site/month and sites opening to recruitment at a rate of 1 per month.
The pscDesign package includes a function [recForcast()] which allows for monthly recruitment estimates.

## ‘Traditional’ design comparisons

As an illustration, we initially examine traditional randomised phase II trial designsetting a HR = 0.7, using an alpha level of 0.1 and power of 90%

### Randomised pahse II study design

    gsdesign.survival(c(1),haz.ratio=0.7,r=1,sig.level=0.1,power=0.9,alternative="one.sided")

     Group sequential design for comparing survival data with hazard ratio = 0.7
       Treatment allocated at 1:1 (C:E) ratio
       power family of boundary; 0 (Pocock) to 0.5 (O'Brien-Fleming)

     total number of events = 206.56
       information fraction = 1
          efficacy boundary = 1.282 (power = 0.5)
                  sig.level = 0.1
                      power = 0.9
                alternative = one.sided

## Syntheticall Controlled Trial Design

We now walk through the steps required to use the pscDesign function. To do this we make use of the gemCFM data

    library(pscDesign)
    #> Loading required package: survival
    library(psc)
    #> Loading required package: ggplot2
    #>
    #> Attaching package: 'psc'
    #> The following object is masked from 'package:pscDesign':
    #>
    #>     gemCFM
    gemCFM <- pscDesign::gemCFM

Before using the pscDesign() function to perform the simulation study, we first ensure the CFM is compatible by simulating a single dataset using the dataSim() function

    simData <- dataSim(gemCFM,n0=0,n1=500,beta=log(0.5),fuTime=12,recTime=24)
    psc.ex <- pscfit(gemCFM,simData)

We can evaluate the fit of this example using the summary and plot() functions

    summary(psc.ex)
    #> Counterfactual Model (CFM):
    #> A model of class 'flexsurvreg'
    #>  Fit with 5 internal knots
    #>
    #> CFM Formula:
    #> Surv(time, cen) ~ LymphN + ResecM + Diff_Status + PostOpCA199
    #> <environment: 0x118659938>
    #>
    #> CFM Summary:
    #> Expected response for the outcome under the CFM:
    #>     S     lo     hi
    #> 23.00  20.61  26.00
    #>
    #> Observed outcome from the Data Cohort:
    #>          [,1]
    #> median   NA
    #> 0.95LCL  NA
    #> 0.95UCL  NA
    #>
    #> MCMC Fit:
    #> Posterior Distribution obtaine with fit summary:
    #>       variable     rhat         ess_bulk     ess_tail     mcse_mean
    #> [1,]  beta_1       1.001954     1001.136     1248.732     0.002850334
    #>
    #> Summary:
    #> Posterior Distribution for beta:Call:
    #>  CFM model + beta
    #>
    #> Coefficients:
    #>            variable    mean        sd          median      q5
    #> posterior  beta_1      -0.782675   0.09049631  -0.7825153  -0.9293457
    #>            q95
    #> posterior  -0.6371023
    plot(psc.ex)
    #>            variable    mean        sd          median      q5
    #> posterior  beta_1      -0.782675   0.09049631  -0.7825153  -0.9293457
    #>            q95
    #> posterior  -0.6371023
    #> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
    #> ℹ Please use `linewidth` instead.
    #> ℹ The deprecated feature was likely used in the ggpubr package.
    #>   Please report the issue at <https://github.com/kassambara/ggpubr/issues>.
    #> This warning is displayed once every 8 hours.
    #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
    #> generated.
    #> Warning: Using the `size` aesthetic in this geom was deprecated in ggplot2 3.4.0.
    #> ℹ Please use `linewidth` in the `default_aes` field and elsewhere instead.
    #> ℹ The deprecated feature was likely used in the survminer package.
    #>   Please report the issue at <https://github.com/kassambara/survminer/issues>.
    #> This warning is displayed once every 8 hours.
    #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
    #> generated.
    #> Ignoring unknown labels:
    #> • colour : "Strata"

### Single Arm Trial Design

We first demonstrate the impact of a single arm trial design. We design the study in 2-steps. Initially we provide a estimated monthly recruitment rate.

#### recruitment forecast

This is based on 4 sites recruiting at an average rate of 0.88 patients/site/month.
Sites will themselves open at a rate of 1 site/month and a maximum recruitment time of 24 months is set. This gives a total sample size of 70 patients.

    N.site <- 4
    rpm <- 0.88
    open.rate <- 1
    recTime <- 24
    recF <- recForcast(N.site,rpm,open.rate,Max.Time=recTime)

#### Power estimates

We run the pscDesign function using the ‘rec=recF’ option to include these recruitment estimates. Other parameters show we are interested in a ningle arm study (n=0) looking for a HR = 0.7 (beta=log(0.7)). We allow for a follow-up period of 12 months and in this example use only 10 simulations (you will want more but we keep this small to keep the processing speed down). We limit the pscfit function to use 750 MCMC iteration and allow the first 250 to act as a burn in.

    pscDes_singArm <- pscDesign(CFM=gemCFM,n0=0,n1=70,beta=log(0.7),rec=recF,
                                    fuTime=12,nsim=10,nsim.psc=750,burn.psc=250,
                                    bound=0,direction="greater",
                                    alpha_eval=c(0.05,0.1,0.15,0.2))

We view the results below showing the esitmated number of events, posterior mean and posterior standard deviation. Also given are the power estiamtes for a range of alpha levels.

    pscDes_singArm
    #> [[1]]
    #>         ne    post_mn    post_sd
    #> 31.0000000 -0.3357661  0.1729714
    #>
    #> [[2]]
    #>   alpha_eval pwrEst
    #> 1       0.05    0.6
    #> 2       0.10    0.7
    #> 3       0.15    0.9
    #> 4       0.20    0.9

### Randomised Trial Design

In a randomised trial design we extend the example to allow 30 patients onto the control arm as well as 70 on the experimental.

#### recruitment forecast

Given the extra patients required we extend recruitment by a period of 6 months.

    N.site <- 4
    rpm <- 0.88
    open.rate <- 1
    recTime <- 30
    recF <- recForcast(N.site,rpm,open.rate,Max.Time=recTime)  #100 patients over 30 months

We ammend the pscDesign() function allowing for control patients (n=30)

    pscDes_rand <- pscDesign(CFM=gemCFM,n0=30,n1=70,beta=log(0.7),rec=recF,
                                    fuTime=12,nsim=5,nsim.psc=750,burn.psc=250,
                                    bound=0,direction="greater",
                                    alpha_eval=c(0.05,0.1,0.15,0.2))

The results of the design given below now include estimates of the efficacy parameter using Personalised Synthetic Controls, Direct Estimation (e.g. using only the information in the trial) and the ‘posterior’ estimate which combines these two efficacy estimates

    pscDes_rand
    #> [[1]]
    #>         ne     mn_psc     sd_psc  mn_direct  sd_direct    post_mn    post_sd
    #> 42.8000000 -0.3194790  0.1715243 -0.1693806  0.3318623 -0.2917477  0.1521509
    #>
    #> [[2]]
    #>   alpha_eval pwrEst
    #> 1       0.05    0.6
    #> 2       0.10    0.6
    #> 3       0.15    0.6
    #> 4       0.20    0.6