Type: Package
Title: Study Design for Personalised Synthetic Controls
Version: 1.0.0
Maintainer: Richard Jackson <richJ23@liverpool.ac.uk>
Description: Tools for the design of prospective studies using Personalised Synthetic Controls. Can be used in either single arm or randomised studies.
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.3
Depends: R (≥ 4.0.0), survival
Imports: psc (≥ 2.0.0), S7
Suggests: knitr
VignetteBuilder: knitr
URL: https://github.com/richJJackson/pscDesign
BugReports: https://github.com/richJJackson/pscDesign/issues
NeedsCompilation: no
Packaged: 2026-01-23 16:48:18 UTC; richardjackson
Author: Richard Jackson ORCID iD [cre, aut, cph]
Repository: CRAN
Date/Publication: 2026-01-27 21:30:12 UTC

Simulate covariates from a Counter factual model

Description

A function to simulate covariate values from a Counter Factual Model

Usage

covSim(CFM, n = 100)

Arguments

CFM

a Counter-Factual model

n

number of observation

Details

This functions extracts the covariates form a counter factual model and samples from them in order to create a simulated dataset.

Value

A cumulative Hazard function


Study design using Personalised Synthetic Controls

Description

pscDesign performs the simulations required to estimate the Power of a study designed using personalised synthetic controls.

Usage

dataSim(CFM, n0 = 0, n1 = 100, beta = 0, fuTime, recTime, rec = NULL)

Arguments

CFM

a Counter-Factual model

n0

number of patients allocated to the control arm (defaults to 0 - i.e. single arm study).

n1

number of patients allocated to the experimental arm

beta

the (log) HR used in the study design

fuTime

Follow up time for the study design

recTime

Recruitment time for the study design

rec

a study recruitment estimate obtained using the recForcast() function. If specified, recTime will be ignored.

Details

The datSim function simulates a dataset including sampled covariatees and outcome data from a counterfactual model

Time parameters (fuTime, recTime) should be expressed on the same scale on which they are specified in the Counter Factual Model. One of recTime or rec must be specified. If rec is specified, recTime will be ignored.

Value

A data frame intended for use with the CFM including covariate and outcome data

Examples

gemCFM <- pscDesign::gemCFM
dataSim(gemCFM,n0=10,n1=20,beta=log(0.7),fuTime=12,recTime=12)

Generate a cumulative hazard function from a flexible parametric model

Description

A function to estimate the survival function based on parameter estimates.

Usage

fpmH(CFM, maxTime = 24)

Arguments

CFM

a Counter-Factual model

maxTime

maximum time used in the estimation

Details

This functions extracts the baseline (cumulative) hazard parameters from a counter factual model. This is used in the simulation of datasets.

Value

A cumulative Hazard function


Generate a survival function from a flexible parametric model

Description

A function to estimate the survival function based on parameter estimates.

Usage

fpmSurv(CFM, beta = NULL, lp = NULL, maxTime = 24)

Arguments

CFM

a Counter-Factual model

beta

parameter with which to adjust the baseline function (defaults to beta=0)

lp

a linear predictor which if supplies will be used to adjust the parameters of the survival function

maxTime

maximum time used in the estimation

Details

This functions extracts the baseline (cumulative) hazard parameters from a counter factual model and uses these to construct survival estimates. This is used in the simulation of datasets. If a (log) hazard ratio, beta, or a linear predictor, lp, are supplied - these will be used to adjust the baseline estimates.

Value

A survival function


gemCFM

Description

Model for a survival outcome based on Gemcitbine patients from ESPAC-3. A generated model with a survival endpoint and a cuymulative hazard function estimated using flexible parametric splines. Data for the model were obtained from the ESPAC-3 trials

Usage

gemCFM

Format

A model of class 'pscCFM' containg a 'flexsurvreg' model:

gamma

cumulative baseline hazard parameters

nodes

negative (n=1) or positive (n=2) lymph nodes

grade

tumour grade (1,2 or 3)

lca199

log transformed ca19.9

ResecM

Resection Margins)

Source

simulated


modp

Description

A function which rrturns either the input value (if positive) or zero (if negative)

Usage

modp(x)

Arguments

x

a numberic vector

Details

A fucntion which returns a version of x with negative values replacd with 0

Value

a numeric vector with negative values replaced with 0


A function to evaluate posterior distribution

Description

postEval evaluated a distribition based on given mean and standard deviation

Usage

postEval(mn, sd, bound = 0, direction = "greater")

Arguments

mn

distribution mean

sd

distribution sd

bound

The bound to use in the posterior evaluation (defaults to 0)

direction

The direction which specifies superiority of the efficacy parameter


Study design using Personalised Synthetic Controls

Description

pscDesign performs the simulations required to estimate the Power of a study designed using personalised synthetic controls.

Usage

pscDesign(
  CFM,
  n0 = 0,
  n1,
  beta,
  fuTime,
  recTime,
  rec = NULL,
  nsim = 4,
  nsim.psc = 500,
  burn.psc = 200,
  bound = 0,
  direction = "greater",
  alpha_eval = c(0.01, 0.025, 0.05, 0.1, 0.15, 0.2)
)

Arguments

CFM

a Counter-Factual model

n0

number of patients allocated to the control arm (defaults to 0 - i.e. single arm study).

n1

number of patients allocated to the experimental arm

beta

the (log) HR used in the study design

fuTime

Follow up time for the study design

recTime

Recruitment time for the study design

rec

a study recruitment estimate obtained using the recForcast() function. If specified, recTime will be ignored.

nsim

number of simulations

nsim.psc

number of simulations to use in psc estimation

burn.psc

burn in to use in psc estimation

bound

The bound to use in the posterior evaluation (defaults to 0)

direction

The direction which specifies superiority of the efficacy parameter

alpha_eval

Alpha values at which to evaluate the study design.

Details

The pscDesign function performs a simulation study to estimate the design parameters for a study using personalised synthetic controls.

Time parameters (fuTime, recTime) should be expressed on the same scale on which they are specified in the Counter Factual Model. One of recTime or rec must be specified. If rec is specified, recTime will be ignored.

Value

A list containing a summary of the simulated datasets and estimated type-II error rates (Power) against leveld of significance (alpha-levels)

Examples

gemCFM <- pscDesign::gemCFM
pscDesign(gemCFM,n0=0,n1=100,beta=log(0.7),fuTime=12,recTime=12,nsim=2,
    nsim.psc=300,burn.psc=100)

Estimating recruitment rates based on the number of sites and average site recruitment rates.

Description

Estimating recruitment rates based on the number of sites and average site recruitment rates.

Usage

recForcast(N.site, rpm, open.rate, Max.Time, penal = 0.5, plot = TRUE, ...)

Arguments

N.site

The number of recruiting sites

rpm

The average recruitment per site per month

open.rate

the rate at which sites are expected to open to recruitment

Max.Time

maximum time used in the estimation

penal

A penalising factor for the recruitment in the intial month for each site (defaults to penal=0.5)

plot

shoud results be plotted?

...

aditional arguments passed to plot

Details

This functions estimates monthly recruitment rates based on the number of sites and the average monthly recruitment rate. The resulting dataset can be passed to pscDesign to improve estimation of design parameters.

Value

A dataset giving the monthly recruitment rate

Examples

recForcast(N.site=5,rpm=1,open.rate=1,Max.Time=12)

Evaluation of a sampled dataset within pscDesign

Description

trialSamp evaluates a sampled dataset and returns the reuslts

Usage

trialSamp(
  CFM,
  n0,
  n1,
  beta,
  fuTime,
  recTime,
  rec,
  nsim.psc = 750,
  burn.psc = 250
)

Arguments

CFM

a Counter-Factual model

n0

number of patients allocated to the control arm (defaults to 0 - i.e. single arm study).

n1

number of patients allocated to the experimental arm

beta

the (log) HR used in the study design

fuTime

Follow up time for the study design

recTime

Recruitment time for the study design

rec

a study recruitment estimate obtained using the recForcast() function. If specified, recTime will be ignored.

nsim.psc

number of simulations to use in psc estimation

burn.psc

burn in to use in psc estimation

Value

The number of events as well as estimates of the posterior mean and standard deviation