| Title: | Study Design for Personalised Synthetic Controls |
|---|---|
| Description: | Tools for the design of prospective studies using Personalised Synthetic Controls. Can be used in either single arm or randomised studies. |
| Authors: | Richard Jackson [cre, aut, cph] (ORCID: <https://orcid.org/0000-0002-7814-5088>) |
| Maintainer: | Richard Jackson <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-06-08 11:01:04 UTC |
| Source: | https://github.com/richjjackson/pscdesign |
A function to simulate covariate values from a Counter Factual Model
covSim(CFM, n = 100)covSim(CFM, n = 100)
CFM |
a Counter-Factual model |
n |
number of observation |
This functions extracts the covariates form a counter factual model and samples from them in order to create a simulated dataset.
A cumulative Hazard function
pscDesign performs the simulations required to estimate the Power of a study designed using personalised synthetic controls.
dataSim(CFM, n0 = 0, n1 = 100, beta = 0, fuTime, recTime, rec = NULL)dataSim(CFM, n0 = 0, n1 = 100, beta = 0, fuTime, recTime, rec = NULL)
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. |
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.
A data frame intended for use with the CFM including covariate and outcome data
gemCFM <- pscDesign::gemCFM dataSim(gemCFM,n0=10,n1=20,beta=log(0.7),fuTime=12,recTime=12)gemCFM <- pscDesign::gemCFM dataSim(gemCFM,n0=10,n1=20,beta=log(0.7),fuTime=12,recTime=12)
A function to estimate the survival function based on parameter estimates.
fpmH(CFM, maxTime = 24)fpmH(CFM, maxTime = 24)
CFM |
a Counter-Factual model |
maxTime |
maximum time used in the estimation |
This functions extracts the baseline (cumulative) hazard parameters from a counter factual model. This is used in the simulation of datasets.
A cumulative Hazard function
A function to estimate the survival function based on parameter estimates.
fpmSurv(CFM, beta = NULL, lp = NULL, maxTime = 24)fpmSurv(CFM, beta = NULL, lp = NULL, maxTime = 24)
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 |
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.
A survival function
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
gemCFMgemCFM
A model of class 'pscCFM' containg a 'flexsurvreg' model:
cumulative baseline hazard parameters
negative (n=1) or positive (n=2) lymph nodes
tumour grade (1,2 or 3)
log transformed ca19.9
Resection Margins)
simulated
A function which rrturns either the input value (if positive) or zero (if negative)
modp(x)modp(x)
x |
a numberic vector |
A fucntion which returns a version of x with negative values replacd with 0
a numeric vector with negative values replaced with 0
postEval evaluated a distribition based on given mean and standard deviation
postEval(mn, sd, bound = 0, direction = "greater")postEval(mn, sd, bound = 0, direction = "greater")
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 |
pscDesign performs the simulations required to estimate the Power of a study designed using personalised synthetic controls.
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) )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) )
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. |
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.
A list containing a summary of the simulated datasets and estimated type-II error rates (Power) against leveld of significance (alpha-levels)
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)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.
recForcast(N.site, rpm, open.rate, Max.Time, penal = 0.5, plot = TRUE, ...)recForcast(N.site, rpm, open.rate, Max.Time, penal = 0.5, plot = TRUE, ...)
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 |
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.
A dataset giving the monthly recruitment rate
recForcast(N.site=5,rpm=1,open.rate=1,Max.Time=12)recForcast(N.site=5,rpm=1,open.rate=1,Max.Time=12)
trialSamp evaluates a sampled dataset and returns the reuslts
trialSamp( CFM, n0, n1, beta, fuTime, recTime, rec, nsim.psc = 750, burn.psc = 250 )trialSamp( CFM, n0, n1, beta, fuTime, recTime, rec, nsim.psc = 750, burn.psc = 250 )
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 |
The number of events as well as estimates of the posterior mean and standard deviation