| Title: | Personalised Synthetic Controls |
|---|---|
| Description: | Allows the comparison of data cohorts (DC) against a Counter Factual Model (CFM) and measures the difference in terms of an efficacy parameter. Allows the application of Personalised Synthetic Controls. |
| Authors: | Richard Jackson [cre, aut, cph] (ORCID: <https://orcid.org/0000-0002-7814-5088>) |
| Maintainer: | Richard Jackson <[email protected]> |
| License: | GPL-3 |
| Version: | 2.1.0 |
| Built: | 2026-06-08 10:51:15 UTC |
| Source: | https://github.com/richjjackson/psc |
Function to accept (or not) a proposed solution used as part of the MCMC procedure
acc(old, new)acc(old, new)
old |
a numeric value |
new |
a numeric value |
A function for the evaluation of two likelihoods as part of the MCMC procedure
returns the an evaluation of old/new > U where U is a draw from the uniform distribution
A generated model with a binary endpoint and a logistic link function. Data for the model were synthetically generated and are based on a dataset to evaulate the use of Sorafenib in HCC akin to the PROSASH model (see ?psc::surv.mod for more details)
bin.modbin.mod
A model of class 'glm':
vascular invasion
ECOG performance Status
AFP - log scale
albumin
Creatinine - log scale
metastesis
simulated
A function to estimate the linear predictor - used in bootstrapping CFM for CIs
boot_lp(i, pscOb, resp = resp, rest = NULL)boot_lp(i, pscOb, resp = resp, rest = NULL)
i |
indicator object |
pscOb |
an object of class 'psc' |
resp |
A boolean object to determine if results should be presented on the response scale |
rest |
A matrix of sample covariate estimates |
A simulated set of responses
A function to estimate the survival function based on parameter estimates - used in ootstrapping CFM for CIs
boot_sest( i, pscOb = pscOb, lam = lam, kn = kn, k = k, cov = cov, tm = tm, rest = rest, beta = beta )boot_sest( i, pscOb = pscOb, lam = lam, kn = kn, k = k, cov = cov, tm = tm, rest = rest, beta = beta )
i |
indicator object |
pscOb |
a pscOb object |
lam |
parameters of the flexible spline model |
kn |
knots included in the flexible spline model |
k |
number of knots in the flexible spline model |
cov |
a matrix of covariates |
tm |
time at which to assess the survival function |
rest |
a set of parameter covariate draws |
beta |
parameter with which to adjust the baseline function |
A set of survival estimates
The pscCFM creates a model object which is stripped of identifiable information. The cfmDataSumm function supplies a tabulated form of the dataset used in the CFM for summary information. Information returned in the form of a table
cfmDataSumm(cfm)cfmDataSumm(cfm)
cfm |
a 'glm' or 'flexsurvreg' model object |
a summary table
The pscCFM creates a model object which is stripped of identifiable information. The cfmDataVis function supplies a visualised form of the dataset for summary information
cfmDataVis(cfm)cfmDataVis(cfm)
cfm |
a 'glm' or 'flexsurvreg' model object |
a list of grobs for each model covariate
A function which summarises categorical data using a bar plot. A sub-function of cfmDataVis
cfmDataVis_fac(x, nm)cfmDataVis_fac(x, nm)
x |
a covariate to be summarised |
nm |
a covariate name |
a ggplot object
A function which summarises categorical data using density plots. A sub-function of cfmDataVis
cfmDataVis_num(x, nm)cfmDataVis_num(x, nm)
x |
a covariate to be summarised |
nm |
a covariate name |
a ggplot object
A generic function to provide a summary of a Counter factual model of class 'glm'
cfmSumm.flexsurvreg(pscOb, bootCI = TRUE, nboot = 1000)cfmSumm.flexsurvreg(pscOb, bootCI = TRUE, nboot = 1000)
pscOb |
an object of class 'psc' |
bootCI |
a boolean to determine if bootstrapping CIs are required |
nboot |
Number of bootstraps |
A summary of a cfm object
A generic function to provide a summary of a Counter factual model of class 'glm'
cfmSumm.glm(pscOb, bootCI = TRUE, nboot = 1000, resp = TRUE)cfmSumm.glm(pscOb, bootCI = TRUE, nboot = 1000, resp = TRUE)
pscOb |
an object of class 'psc' |
bootCI |
a boolean to determine if bootstrapping CIs are required |
nboot |
Number of bootstraps |
resp |
Should results be on the response scale? |
A summary of a cfm object
Returns basic measures of the posterior distribution obtained from the psc object
## S3 method for class 'psc' coef(object, ...)## S3 method for class 'psc' coef(object, ...)
object |
a 'psc' object |
... |
not used |
The summary of the posterior distribution for the efficacy parameter in terms of the median and 95
A generated model with a continuous data endpoint and a identity link function. Data for the model were synthetically generated and are based on a dataset to evaulate the use of Sorafenib in HCC akin to the PROSASH model (see ?psc::surv.mod for more details)
cont.modcont.mod
A model of class 'glm':
ECOG performance Status
AFP - log scale
albumin
Creatinine - log scale
simulated
A generated model with a count data endpoint and a log link function. Data for the model were synthetically generated and are based on a dataset to evaulate the use of Sorafenib in HCC akin to the PROSASH model (see ?psc::surv.mod for more details)
count.modcount.mod
A model of class 'glm':
ECOG performance Status
AFP - log scale
albumin
Creatinine - log scale
simulated
A dataset containing 100 simulated patients. Data are based on the data used to generate PROSASH survival model -see ?psc::surv.mod for more detials.
datadata
A model of class 'flezsurvreg':
cumulative baseline hazard parameters
vascular invasion
patient age (centred at 60)
ECOG performance Status
AFP - log scale
albumin
Creatinine - log scale
metastesis
centred age nested within vascular invasion
survival time
censoring indicator
survival time
exapmple outcome for count data
exapmple identifier for mulitple treatment comparisons
Aetiology
simulated
A dataset containing 346 simulated patients. Data are based on the patietns randomised to revceive GemCap in the ESPAC-4 trial
e4_datae4_data
A model of class 'flezsurvreg':
survival time
censoring indicator
negative (n=1) or positive (n=2) lymph nodes
tumour grade (1,2 or 3)
log transformed ca19.9
T-stage (1,2 or 3)
simulated
A function which compares visually a new categorical covariate against equivalent data from a CFM
facVisComp(p, x)facVisComp(p, x)
p |
a ggplot objects |
x |
a categorical covariate |
a ggplot object
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
Function for estimating initial parameter values
init(pscOb)init(pscOb)
pscOb |
a psc object |
This function takes the likelihood and data structures provided by the pscData() strucutres and fits the likelihood to provide starting values for MCMC estimation
Parameter Estimates and standard error for the efficacy parameter
A function which defines the likelihood for a PSC model where the Counter
Factual Model (CFM) takes the form of a 'flexsurvreg' object and an efficacy
parameter () is being estimated. For more details on fitting please see
?pscfit and ?pscEst
lik.flexsurvreg(beta, pscOb)lik.flexsurvreg(beta, pscOb)
beta |
a parameter to be estimate |
pscOb |
A pscOb object containing a cleaned dataset including covariates to match the CFM |
A likelihood function for use by pscfit for a model of class 'flexsurvreg'
the results of a likelihood functions
A function which defines the likelihood for a PSC model where the Counter
Factual Model (CFM) takes the form of a 'glm' object and an efficacy
parameter () is being estimated. For more details on fitting please see
?pscfit and ?pscEst
lik.glm(beta, pscOb)lik.glm(beta, pscOb)
beta |
a parameter to be estimate |
pscOb |
a pscOb object containing a cleaned dataset including covariates to match the CFM |
A likelihood function for use by pscfit for a model of class 'glm'
the results of a likelihood functions
A generic function for extracting model information
modelExtract(CFM)modelExtract(CFM)
CFM |
a model of class either 'glm' or 'flexsurvreg' |
A function for extracting the model information required for using pscfit
a list of extracted model components
A generic function for extracting model information
## S3 method for class 'flexsurvreg' modelExtract(CFM)## S3 method for class 'flexsurvreg' modelExtract(CFM)
CFM |
a model of class either 'flexsurvreg' |
A function for extracting the model information required for using pscfit
a list of extracted model components
A generic function for extracting model information
## S3 method for class 'glm' modelExtract(CFM)## S3 method for class 'glm' modelExtract(CFM)
CFM |
a model of class either 'glm' |
A function for extracting the model information required for using pscfit
a list of extracted model components
A generic function for extracting model information
## S3 method for class 'lmerMod' modelExtract(CFM)## S3 method for class 'lmerMod' modelExtract(CFM)
CFM |
a model of class either 'lmer' |
A function for extracting the model information required for using pscfit
a list of extracted model components
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
A function which summarises numerical data using a density plots
numVisComp(p, x)numVisComp(p, x)
p |
a ggplot object |
x |
a numeric vector |
a ggplot object
A function which illsutrates the predicted response under the Counter Factual Model (CFM) and the observed response under the experimental treatment(s). Form of the output will depend on the form of the CFM used
## S3 method for class 'psc' plot(x, ...)## S3 method for class 'psc' plot(x, ...)
x |
an object of class 'psc' |
... |
not used |
This function plots the expected response of the control treatment along with the observe response rates of the experimental arms
a survival plot corresponding to the psc fit
e4_data <- psc::e4_data gemCFM <- psc::gemCFM psc <- pscfit(gemCFM,e4_data,nsim=1500,nchain=1) plot(psc)e4_data <- psc::e4_data gemCFM <- psc::gemCFM psc <- pscfit(gemCFM,e4_data,nsim=1500,nchain=1) plot(psc)
A function which illsutrates the predicted response under the counter factual model and the observed response under the experimental treatment(s).
## S3 method for class 'psc.binary' plot(pscOb, ...)## S3 method for class 'psc.binary' plot(pscOb, ...)
pscOb |
an object of class 'psc' |
... |
not used |
This function plots the expected response of the control treatment along with the observe response rates of the experimental arms
a survival plot corresponding to the psc fit
A function which illsutrates the predicted response under the counter factual model and the observed response under the experimental treatment(s).
## S3 method for class 'psc.cont' plot(x, ...)## S3 method for class 'psc.cont' plot(x, ...)
x |
an object of class 'psc' |
... |
not used |
This function plots the expected response of the control treatment along with the observe response rates of the experimental arms
a survival plot corresponding to the psc fit
Function for Plotting PSC objects #' A function which illsutrates the predicted response under the counter factual model and the observed response under the experimental treatment(s).
## S3 method for class 'psc.count' plot(x, ...)## S3 method for class 'psc.count' plot(x, ...)
x |
an object of class 'psc' |
... |
not used |
This function plots the expected response of the control treatment along with the observe response rates of the experimental arms
a survival plot corresponding to the psc fit
Function for Plotting PSC objects
## S3 method for class 'psc.flexsurvreg' plot(pscOb, addFit = T, ...)## S3 method for class 'psc.flexsurvreg' plot(pscOb, addFit = T, ...)
pscOb |
an object of class 'psc' |
addFit |
should a curve for the model fit be added? |
... |
not used |
making use of 'ggsurvplot' in the survminer package, this function plots the expected survival funtion for the 'control' treatment estimated from the CFM along with the Kaplan Meier estimates of the observed events
a survival plot corresponding to the psc fit
A function which visualises the data of a CFM or the combined CFM and DC data for a 'psc' obecjec
plotCFM(x, ...)plotCFM(x, ...)
x |
an object of class 'CFM' or 'psc' |
... |
not used |
This function returns either density plots (continuous data) or bar plots (categroical data) to describe the data in the CFM. If an object is supplied which has combied the CFM and DC (e.g. a psc object or an object which has been passed through pscData()) then a comparison of the CFM and DC will be supplied
a plot to describe the data included in the models
e4_data <- psc::e4_data gemCFM <- psc::gemCFM plotCFM(gemCFM) psc <- pscfit(gemCFM,e4_data,nsim=2000,nchain=1) plotCFM(psc)e4_data <- psc::e4_data gemCFM <- psc::gemCFM plotCFM(gemCFM) psc <- pscfit(gemCFM,e4_data,nsim=2000,nchain=1) plotCFM(psc)
A function that provides a summary of the posterior distributions obtained from a pscEst() procedures
postSummary(pscOb, thin = 2, burn = 1000, par = "beta")postSummary(pscOb, thin = 2, burn = 1000, par = "beta")
pscOb |
a pscOb function which has passed through pscEst() |
thin |
a thin to be applied to the posterior distributions |
burn |
a burnin to ba applied to the posterior distribution |
par |
the parameter to be summarised - defaults to 'beta' to summarise all 'beta' parameters in the posterior distribution |
This function makes use of the 'posterior' package to pull together each of the 'draw' matrices included in the psc object and produce posterior summaries
Returns a summary of a 'psc' object including details on the original Counter Factual Model, a summary of the Data Cohort, the predicted responses from the CFM and details on the model fit.
e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data) pscOb <- init(pscOb) pscOb <- pscEst(pscOb) pscOb <- postSummary(pscOb)e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data) pscOb <- init(pscOb) pscOb <- pscEst(pscOb) pscOb <- postSummary(pscOb)
Personalised Synthetic Controls - print
## S3 method for class 'psc' print(x, ...)## S3 method for class 'psc' print(x, ...)
x |
an object of class 'psc' |
... |
not used |
printing psc results
Ensuring a quiet list of the grobs data are supplied to cfmDataVis
## S3 method for class 'quiet_gglist' print(x, ...)## S3 method for class 'quiet_gglist' print(x, ...)
x |
an object of class 'psc' |
... |
not used |
A quiet list
Ensuring a quiet list of the grobs data are supplied to cfmDataVis
## S3 method for class 'quiet_gtsumm' print(x, ...)## S3 method for class 'quiet_gtsumm' print(x, ...)
x |
an object of class 'psc' |
... |
not used |
A quiet list
Ensuring a quiet list of the grobs data are supplied to cfmDataVis
## S3 method for class 'quiet_list' print(x, ...)## S3 method for class 'quiet_list' print(x, ...)
x |
an object of class 'psc' |
... |
not used |
A quiet list
psc objectAn object returned by the pscfit function, inheriting from class
psc and representing a fitted personalised synthetic control model.
psc.objectpsc.object
An object of class NULL of length 0.
Richard Jasckson ([email protected])
Standard R model objects contain within them the datasets used to create the model and as such care is needed when sharing these objects for research. The psc.cfm function creates an object with all identifiable information retracted and includes only the information required to use the models within the psc package
pscCFM(CFM, dataSumm = T, dataVis = T)pscCFM(CFM, dataSumm = T, dataVis = T)
CFM |
a 'glm' or 'flexsurvreg' model object |
dataSumm |
a logical indicator specifying whether a summary of the data should be provided, defaults to TRUE. |
dataVis |
a logical indicator specifying whether a visualisations of the data should be provided, defaults to TRUE. |
a list containing objects which specify the required exported components of the model.
This function allows the combination of estimation where mulitple treatment comparisons are being made and one of the treatment levels relates to the control level. Note here it is assumed that the control level is coded trt=0. This function then combines the two efficacy estimates for the treatment effect (concurrent and synhtetic) whilst accounting for the correlation inherent in these two estimates.
pscComb(x)pscComb(x)
x |
A pscfit object with 2 treatment comparions |
This function ensures the data are supplied in a structure which allows for estimation. This is performed by re-fitting the original CFM with the DC and extracting the appropriate structures. Data are returned in terms of "Y" for model outcomes, "X" for data and "Z" for random effects where mixed models are supplied.
pscData(CFM, DC, id = NULL, trt = NULL)pscData(CFM, DC, id = NULL, trt = NULL)
CFM |
a Counter Factual Model |
DC |
a Data Cohort object |
id |
to be specified for subgroup analysis. Defaults to NULL |
trt |
to be specified for multiple treatment comparisons. Defaults to NULL |
A set of structures for use with estimation procedures
e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data)e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data)
The purpose of this function is to include the appropriate likelihood to the psc object for estimation procedures
pscData_addLik(CFM)pscData_addLik(CFM)
CFM |
A counter factual model |
a likelihood function
The purpose of this function is to organise a treatment indicator where multiple treatment comparisons are being evaluated. This acts as a sub-function to the pscData.R function.
pscData_addtrt(DC, trt)pscData_addtrt(DC, trt)
DC |
a data cohort to be 'cleaned' |
trt |
a treatment indicator |
a dataset which is checked and compatible with the CFM
The purpose of this function is check that terms included in the Data Cohort match those used within the Counter Factual Model. This acts as a sub-function to the pscData.R function.
pscData_error(term.nm, DC)pscData_error(term.nm, DC)
term.nm |
Term names from the CFM |
DC |
a data cohort to be 'cleaned' |
a 'stop' command when errors are detected
The purpose of this function is to run a series of checks to ensure that the data included in the data cohort is comparable to the counter-factual model. This matches the data classes and checks the levels in the DC match those used in the CFM. This acts as a sub-function to the pscData.R function.
pscData_match(cls, lev, DC)pscData_match(cls, lev, DC)
cls |
a list of extracted data classes |
lev |
a list of factor levels |
DC |
a data cohort to be 'cleaned' |
a dataset which is checked and compatible with the CFM
Currently the psc package works only on complete-case datasets. This function removes rows with missing data and returns a warning to inform the user. This acts as a sub-function to the pscData.R function.
pscData_miss(DC)pscData_miss(DC)
DC |
a data cohort to be 'cleaned' |
a dataset with missing data removed
This function ensures the data are supplied in a structure which allows for estimation. This is performed by re-fitting the original CFM with the DC and extracting the appropriate structures. Data are returned in terms of "Y" for model outcomes, "X" for data and "Z" for random effects where mixed models are supplied.
pscData_structure(CFM, DC)pscData_structure(CFM, DC)
CFM |
a Counter Factual Model |
DC |
a Data Cohort object |
A set of structures for use with estimation procedures re-export Surv from survival
Function for performing Bayesian MCMC estimation procedures in 'pscfit'
pscEst(pscOb, nsim = 1000, nchain = 1)pscEst(pscOb, nsim = 1000, nchain = 1)
pscOb |
an pscOb object which has been passed through pscData() and init() functions |
nsim |
the number of MCMC simulations to run |
nchain |
Number of chains to use for analysis |
Define the set of model parameters to contain which summarize
the parameters of the CFM. Prior distributions are defined for B using a
multivariate normal distribution where
is the vector of coefficient estimates from the validated model and
is the variance-covariance matrix. This information is taken directly from the
outputs of the parametric model and no further elicitation is required.
The prior distirbution for the efficacy parameter () is set
as an uniformative .
Ultimately the aim is to estimate the posterior distribution for conditional
on the distribution of B and the observed data. A full form for the posterior
distribution is then given as
Please see 'pscfit' for more details on liklihood formation.
For each iteration of the MCMC procedure, the following algorithm is performed
Set and indicator s=1, and define an initial state based on prior
hyperparameters for and such that
Update and draw model parameters from and an draw a
proposal estimate of from some target distribution
Estimate where is the subset of parameters from
which relate to the model covariates and define 2 new likelihood functions
&
Draw a single value from a Uniform (0,1) distribution and estimate
the condition . If then accept as belonging
to the posterior distribution otherwise retain
Repeat steps 2 – 4 for the required number of iterations
The result of the algorithm is a posterior distribution for the log hazard ratio,
, captures the variability in B through the defined priors .
@examples
e4_data <- psc::e4_data
gemCFM <- psc::gemCFM
pscOb <- pscData(gemCFM,e4_data)
pscOb <- init(pscOb)
pscOb <- pscEst(pscOb,nsim=1500,nchain=1)
importFrom survival Surv survfit
A matrix containing the draws form the posterior distribution
Running the Bayesian MCMC routine A procedure which runs the MCMC estimation routine
pscEst_run(pscOb, nsim, nchain)pscEst_run(pscOb, nsim, nchain)
pscOb |
an pscOb object which has been passed through pscData() and init() functions |
nsim |
the number of MCMC simulations to run |
nchain |
Number of chains to use for analysis |
An updated set of attributes for the pscOb which includes
e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data) pscOb <- init(pscOb) pscOb <- pscEst_start(pscOb,nsim=1000,nchain=2) pscOb <- pscEst_run(pscOb,nsim=1000,nchain=2)e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data) pscOb <- init(pscOb) pscOb <- pscEst_start(pscOb,nsim=1000,nchain=2) pscOb <- pscEst_run(pscOb,nsim=1000,nchain=2)
Starting conditions for Bayesian MCMC estimation procedures in 'pscfit' A procedure which runs the sampling process for MCMC estimation
pscEst_samp(pscOb, nsim)pscEst_samp(pscOb, nsim)
pscOb |
an pscOb object which has been passed through pscData() and init() functions |
nsim |
the number of MCMC simulations to run |
An updated set of attributes for the pscOb which includes
Starting conditions for Bayesian MCMC estimation procedures in 'pscfit' A procedure which sets the starting conditions for MCMC estimation
pscEst_start(pscOb, nsim, nchain)pscEst_start(pscOb, nsim, nchain)
pscOb |
an pscOb object which has been passed through pscData() and init() functions |
nsim |
the number of MCMC simulations to run |
nchain |
Number of chains to use for analysis |
A procedure which sets the starting conditions for MCMC estimation including defining starting estimates, setting a matrix for draws to be save in and defining, target and prior distributions and deifnign the posterior desitribution from the CFM. This also sets the number of cores to be used for estimation where parallel computing is applied.
An updated set of attributes for the pscOb which includes
e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data) pscOb <- init(pscOb) pscOb <- pscEst_start(pscOb,nsim=1000,nchain=2)e4_data <- psc::e4_data gemCFM <- psc::gemCFM pscOb <- pscData(gemCFM,e4_data) pscOb <- init(pscOb) pscOb <- pscEst_start(pscOb,nsim=1000,nchain=2)
Updating the posterior distribution as part of the MCMC estimation process A procedure which performs a single update of the posterior distribution
pscEst_update(i, draws, pscOb)pscEst_update(i, draws, pscOb)
i |
index of the draw number (i>1) |
draws |
a matrix containing the posterior draws to update |
pscOb |
an pscOb object which has been passed through pscData() and init() functions |
An updated set of posterior draws
Function which allows comparison of a data cohort against a parametric Counter Factual Model (CFM). The function allows models of the type 'flexsurvreg' and 'glm' to be supplied. The function performs by calculating the linear predictor as a combination of the CFM and the dataset supplied and then selects a likelihood based on the type of model specified. Likelihood is estimated using a Baysian MCMC procedure wherebey the parameters of the CFM acts as informative priors.
pscfit( CFM, DC, nsim = 2000, id = NULL, trt = NULL, nchain = 1, thin = 2, burn = 500 )pscfit( CFM, DC, nsim = 2000, id = NULL, trt = NULL, nchain = 1, thin = 2, burn = 500 )
CFM |
An R model object of class 'glm' or 'flexsurvspline' |
DC |
A dataset including columns to match to covariates in the model |
nsim |
The number of simulations for the MCMC routine |
id |
Numeric vector stating which patient(s) from the dataset should be included in the analysis. Defaults to all patients |
trt |
An optional vector denoting treatment allocations for multiple treatment comparisons. Defaults to NULL. |
nchain |
Number of chains used in posterior MCMC estimation. Defaults to nchain=3. |
thin |
Thin applied to posterior draws. Defaults to thin=2. |
burn |
Number of posterior samples to use as burn-in. Defaults to burn=500 |
Model currently supports estimation of more than one treatment (using the 'trt') option and esitmation restricted to sub-groups of the data cohort (using the 'id' option.
the pscfit function compares a dataset ('DC') against a parametric model.
This is done by selecting a likelihood which is identified by the type of CFM that is supplied.
At present, two types of model are supported, a flexible parmaeteric survival model of type 'flexsurvreg'
and a geleneralised linear model of type 'glm'.
Where the CFM is of type 'flexsurvreg' the likeihood supplied is of the form:
Where defines the cumulative baseline hazard function,
is the linear predictor and and are the
event time and indicator variables.
Where the CFM is of the type 'glm' the likelihood supplied is of the form:
Where , and represent the functions of the
exponential family. In both cases, is defined as:
Where are the model coefficients supplied by the CFM and
is the parameter set to measure the difference between the CFM and the DC.
Estimation is performed using a Bayesian MCMC procedure. Prior distributions
for (& ) are derived directly from the model
coefficients (mean and variance covariance matrix) or the CFM. A bespoke MCMC
routine is performed to estimate . Please see '?mcmc' for more detials.
For the standard example where the DC contains information from only a single treatment, trt need not be specified. Where comparisons between the CFM and multiple treatments are require, a covariate of treamtne allocations must be specified sperately (using the 'trt' option).
a object of class 'psc' with attributes model.type, the cleaned Dataset and the posterior distribution of the fitted model
Attributes include
A 'cleaned' dataset including extracted components of the CFM and the cleaned DC included in the procedure
An object defining the class of model (and therefore the procedure applied - see above)
A matrix containing the draws of the posterior distributions
e4_data <- psc::e4_data gemCFM <- psc::gemCFM psc <- pscfit(gemCFM,e4_data,nsim=1500,nchain=1) print(psc)e4_data <- psc::e4_data gemCFM <- psc::gemCFM psc <- pscfit(gemCFM,e4_data,nsim=1500,nchain=1) print(psc)
A function to estimate the survival function based on parameter estimates - used in ootstrapping CFM for CIs
spline_surv_est(lam, kn, k, haz_co, cov_co, cov = cov, tm = tm, beta = 0)spline_surv_est(lam, kn, k, haz_co, cov_co, cov = cov, tm = tm, beta = 0)
lam |
parameters of the flexible spline model |
kn |
knots included in the flexible spline model |
k |
number of knots in the flexible spline model |
haz_co |
parameters for the baseline hazard function in the flexible spline model |
cov_co |
covariate parameters of the flexible spline model |
cov |
a matrix of covaraites from the Data Cohort |
tm |
time at which to assess the survival function |
beta |
parameter with which to adjust the baseline function (defaults to beta=0) |
A data frame containing survival estimates for a give time
A generic function to provide a summary of a 'psc' object obtained from pscfit.R
## S3 method for class 'psc' summary(object, ...)## S3 method for class 'psc' summary(object, ...)
object |
an object of class 'psc' |
... |
not used |
A summary of a psc object obtained using pscSumm and a copy of the pscfit object
e4_data <- psc::e4_data gemCFM <- psc::gemCFM psc <- pscfit(gemCFM,e4_data,nsim=1500,nchain=1) summary(psc)e4_data <- psc::e4_data gemCFM <- psc::gemCFM psc <- pscfit(gemCFM,e4_data,nsim=1500,nchain=1) summary(psc)
A generated model with a survival endpoint and a cuymulative hazard function estimated using flexible parametric splines. Data for the model were synthetically generated and are based on a dataset to evaulate the use of Sorafenib in HCC akin to the PROSASH model
surv.modsurv.mod
A model of class 'flezsurvreg':
cumulative baseline hazard parameters
vascular invasion
patient age (centred at 60)
ECOG performance Status
AFP - log scale
albumin
Creatinine - log scale
metastesis
centred age nested within vascular invasion
survival time
censoring indicator
survival time
de
exapmple outcome for count data
exapmple identifier for mulitple treatment comparisons
Aetiology
simulated
Using prognostic and predictive clinical features to make personalised survival prediction in advanced hepatocellular carcinoma patients undergoing sorafenib treatment. Berhane S, et al., Br J Cancer. 2019 Jul;121(2):117-124
The visComp function takes the data visualisations supplied as part of the CFM model and appends summaries of the equivalent datapoints from the Data Cohort.
visComp(CFM, DC, id = NULL)visComp(CFM, DC, id = NULL)
CFM |
an object of class pscCFM |
DC |
A dataset including columns to match to covariates in the model |
id |
Numeric vector stating which patient(s) from the dataset should be included in the analysis. Defaults to all patients |
a list of grobs for each model covariate