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] |
Maintainer: | Richard Jackson <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-25 16:27:05 UTC |
Source: | CRAN |
acc
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 model of class 'glm'
bin.mod
bin.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
exapmple outcome for count data
exapmple identifier for mulitple treatment comparisons
Aetiology
simulated
Returns the coefficeint estimate of a psc object.
## S3 method for class 'psc' coef(object, ..., level = 0.05)
## S3 method for class 'psc' coef(object, ..., level = 0.05)
object |
a 'psc' object |
... |
not used |
level |
the level at which credibility intervals are assessed, defaults to 0.05 |
The summary of the posterior distribution for the efficacy parameter in terms of the median and 95
A model of class 'glm'
cont.mod
cont.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 vasculdevar invasion
survival time
censoring indicator
survival time
exapmple outcome for count data
exapmple identifier for mulitple treatment comparisons
Aetiology
simulated
A model of class 'glm'
count.mod
count.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
exapmple outcome for count data
exapmple identifier for mulitple treatment comparisons
Aetiology
simulated
A dataset containing 100 simulated patients.
data
data
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 generic function for cleaning data ready for analysis
dataComb(CFM, DC, id = NULL, trt = NULL)
dataComb(CFM, DC, id = NULL, trt = NULL)
CFM |
a model object supplied to pscfit |
DC |
a dataset including covariates to match the CFM |
id |
to specify which observations in the data cohort should be evaluated. Defualts to 'NULL' i.e all observations |
trt |
used to specify multiple treatment effects. Defaults to NULL |
datComb returns a list containing objects which detial the components of both the Counter Factual Model (CFM) and the Data Cohort (DC) the required exported components of the model and a cleaned data cohort.
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data)
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data)
Fucntion for cleaning the data of a model with class 'flexsurvreg'
## S3 method for class 'flexsurvreg' dataComb(CFM, DC, id = NULL, trt = NULL)
## S3 method for class 'flexsurvreg' dataComb(CFM, DC, id = NULL, trt = NULL)
CFM |
a model object supplied to pscfit |
DC |
a dataset including covariates to match the CFM |
id |
a vector specifiying whether a subset of the dataset should be selected. Defaults to 'NULL' e.g. all data points included |
trt |
An optional additional vector denoting treatment allocations for multiple treatment comparisons. Defaults to 'NULL' |
a list containing objects which specifiy the required exported components of the model and a cleaned data cohort.
Fucntion for cleaning the data of a model with class 'flexsurvreg'
## S3 method for class 'glm' dataComb(CFM, DC, id = NULL, trt = NULL)
## S3 method for class 'glm' dataComb(CFM, DC, id = NULL, trt = NULL)
CFM |
a model object supplied to pscfit |
DC |
a dataset including covariates to match the CFM |
id |
to specify which observations in the data cohort should be evaluated. Defualts to 'NULL' i.e all observations |
trt |
used to specify multiple treatment effects. Defaults to NULL |
a list containing objects which specifiy the required exported components of the model and a cleaned data cohort.
Fucntion for estimating initial parameter values 'flexsurvreg'
initParm(CFM, DC_clean, trt)
initParm(CFM, DC_clean, trt)
CFM |
A counter-factual model |
DC_clean |
a cleaned dataset obsect obtained using dataComb.flexsurvreg |
trt |
An optional additional vector denoting treatment allocations for multiple treatment comparisons. Defaults to 'NULL' |
This function takes the liklihood for a 'flexsurvreg' model and uses 'optim' to fit the likelihood.
an 'optim' output giving the parameter values to be supplied as a starting value for the mcmc routine.
Fucntion for estimating initial parameter values 'flexsurvreg'
## S3 method for class 'flexsurvreg' initParm(CFM, DC_clean, trt = NULL)
## S3 method for class 'flexsurvreg' initParm(CFM, DC_clean, trt = NULL)
CFM |
A counter-factual model |
DC_clean |
a cleaned dataset obsect obtained using dataComb.flexsurvreg |
trt |
An optional additional vector denoting treatment allocations for multiple treatment comparisons. Defaults to 'NULL' |
This function takes the liklihood for a 'flexsurvreg' model and uses 'optim' to fit the likelihood.
an 'optim' output giving the parameter values to be supplied as a starting value for the mcmc routine.
Fucntion for estimating initial parameter values 'flexsurvreg'
## S3 method for class 'glm' initParm(CFM, DC_clean, trt = trt)
## S3 method for class 'glm' initParm(CFM, DC_clean, trt = trt)
CFM |
A counter-factual model |
DC_clean |
a cleaned dataset obsect obtained using dataComb.flexsurvreg |
trt |
An optional additional vector denoting treatment allocations for multiple treatment comparisons. Defaults to 'NULL' |
This function takes the liklihood for a 'flexsurvreg' model and uses 'optim' to fit the likelihood.
an 'optim' output giving the parameter values to be supplied as a starting value for the mcmc routine.
Likelihood functio for a a psc model of class 'flexsurvreg'
lik.flexsurvreg(beta, DC_clean)
lik.flexsurvreg(beta, DC_clean)
beta |
a parameter to be estimate |
DC_clean |
a cleaned dataset including covariates to match the CFM |
A likelihood function for use by pscfit for a model of class 'flexsurvreg'
Likelihood functio for a a psc model of class 'flexsurvreg'
lik.flexsurvreg.mtc(beta, DC_clean)
lik.flexsurvreg.mtc(beta, DC_clean)
beta |
a parameter to be estimate |
DC_clean |
a cleaned dataset including covariates to match the CFM |
A likelihood function for use by pscfit for a model of class 'flexsurvreg' where mulitple treatment comparisons are
Likelihood functio for a a psc model of class 'glm'
lik.glm(beta, DC_clean)
lik.glm(beta, DC_clean)
beta |
a parameter to be estimate |
DC_clean |
a cleaned dataset including covariates to match the CFM |
A likelihood function for use by pscfit for a model of class 'flexsurvreg'
Likelihood functio for a a psc model of class 'flexsurvreg'
lik.glm.mtc(beta, DC_clean)
lik.glm.mtc(beta, DC_clean)
beta |
a parameter to be estimate |
DC_clean |
a cleaned dataset including covariates to match the CFM |
A likelihood function for use by pscfit for a model of class 'flexsurvreg' where mulitple treatment comparisons are
Estimates the linear predictor of a psc object
linPred(DC_clean, resp = FALSE)
linPred(DC_clean, resp = FALSE)
DC_clean |
a cleaned data obhject created using dataComb() |
resp |
detailing whether the linear predictor shoudl be returned on the natural or response level. Defaults to the natural scale (resp=F) |
A function which combines the data from the data cohort against the model parameters of the PSC
Extracts the linear predictor from a object containing both a counter factual model and a data cohort which is created using the dataComb() fucntion.
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data) lp <- linPred(dc)
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data) lp <- linPred(dc)
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 '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 'glm' |
A function for extracting the model information required for using pscfit
a list of extracted model components
modp
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
Fucntion for Plotting PSC objects
## S3 method for class 'psc' plot(x, ...)
## S3 method for class 'psc' plot(x, ...)
x |
an object of class 'psc' |
... |
not used |
making use of the generic 'plot' functions this will provide some graphical output of the fitted psc object. The form of the output will depend on the class of the initial model
a plot corresponding to the psc fit
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
Wrapper function for individual treatment effects
psc_ite(model, data)
psc_ite(model, data)
model |
a CFM |
data |
a data cohort |
A wrapper function that estimates individual treatment effects usinf pscfit
psc
objectAn object returned by the pscfit
function, inheriting from class
psc
and representing a fitted personlised synthetic control model.
psc.object
psc.object
An object of class NULL
of length 0.
Richard Jasckson ([email protected])
Function for performing estimation procedures in 'pscfit'
pscEst(CFM, DC_clean, nsim, start, trt)
pscEst(CFM, DC_clean, nsim, start, trt)
CFM |
a model object supplied to pscfit |
DC_clean |
a cleaned dataset ontained using dataComb(). |
nsim |
the number of MCMC simulations to run |
start |
the stating value for |
trt |
an optional vector denoting treatment allocations where mulitple treatment comparisons are bieng made |
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
.
A matrix containing the draws form the posterior distribution
Fucntion for estimating initial parameter values 'flexsurvreg'
## S3 method for class 'flexsurvreg' pscEst(CFM, DC_clean, nsim, start, trt = trt)
## S3 method for class 'flexsurvreg' pscEst(CFM, DC_clean, nsim, start, trt = trt)
CFM |
a model object supplied to pscfit |
DC_clean |
a cleaned dataset ontained using dataComb(). |
nsim |
the number of MCMC simulations to run |
start |
the stating value for |
trt |
an optional vector denoting treatment allocations where multiple treatment comparisons are being made |
An MCMC routine for fitting a psc model
A matrix containing the draws form the posterior distribution
Fucntion for estimating initial parameter values 'glm'
## S3 method for class 'glm' pscEst(CFM, DC_clean, nsim, start, trt = trt)
## S3 method for class 'glm' pscEst(CFM, DC_clean, nsim, start, trt = trt)
CFM |
a model object supplied to pscfit |
DC_clean |
a cleaned dataset ontained using dataComb(). |
nsim |
the number of MCMC simulations to run |
start |
the stating value for |
trt |
an optional vector denoting treatment allocations where multiple treatment comparisons are being made |
An MCMC routine for fitting a psc model
a matrix containing the draws form the posterior distribution
Personalised Synthetic Controls model fit
pscfit(CFM, DC, nsim = 5000, id = NULL, trt = NULL)
pscfit(CFM, DC, nsim = 5000, id = NULL, trt = NULL)
CFM |
A model of type '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. |
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
library(psc) library(survival) data("surv.mod") data("data") surv.psc <- pscfit(surv.mod,data)
library(psc) library(survival) data("surv.mod") data("data") surv.psc <- pscfit(surv.mod,data)
Personalised Synthetic Controls - summary
pscSumm(DC_clean)
pscSumm(DC_clean)
DC_clean |
a cleaned dataset ontained using dataComb(). |
psc summary results including an estimate of the linear predictor combing the data and the model, an estimate of patient level response and summary statistics of the average responses for the sythenthic and observed populations
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data) summ <- pscSumm(dc)
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data) summ <- pscSumm(dc)
Personalised Synthetic Controls - summary
## 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
library(psc) library(survival) data("surv.mod") data("data") psc.ob <- pscfit(surv.mod,data) summary(psc.ob)
library(psc) library(survival) data("surv.mod") data("data") psc.ob <- pscfit(surv.mod,data) summary(psc.ob)
modp
surv_fpm(DC_clean, beta = 0, s = NULL)
surv_fpm(DC_clean, beta = 0, s = NULL)
DC_clean |
a cleaned dataset ontained using dataComb(). |
beta |
a parameter to determine if the survival probabilities should be adjusted by some (log) hazard ratio. Defaults to beta=0, i.e. no adjustment. |
s |
if specified will return the time at which some threshold is passed (e.g. s=0.5 for median survival time) |
A fucntion which extracts survival probabilities from a flexsurvreg object
a list of times and assoicated survival probabilities
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data) s_est <- surv_fpm(dc)
library(psc) library(survival) data("surv.mod") data("data") dc <- dataComb(surv.mod,data) s_est <- surv_fpm(dc)
A model of class 'flezsurvreg'
surv.mod
surv.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
exapmple outcome for count data
exapmple identifier for mulitple treatment comparisons
Aetiology
simulated