Title: | Extensions To Rpsftm Package |
---|---|
Description: | A collection of extenstions to the rpsftm package to enable descriptive analysis of trials affected by treatment switching and enable additional analysis of rpsft models. |
Authors: | Iain Bennett [aut, cre], F. Hoffmann La Roche Ltd [cph] |
Maintainer: | Iain Bennett <[email protected]> |
License: | Apache License (>= 2) |
Version: | 1.0.0 |
Built: | 2024-12-07 03:08:07 UTC |
Source: | https://github.com/Roche/rpsftmPlus |
This function returns a data frame containing following variables derived from a survfit object. Extends the S3 survfit class.
t - Time
s - KM Survival estimate
c - Censoring indicator - 0 is censored, 1 is event
strata - character description of strata that survival estimates are for
Plus all strata variables
## S3 method for class 'survfit' as.data.frame(x)
## S3 method for class 'survfit' as.data.frame(x)
x |
survfit object (survival) |
library(survival) sf <- survfit(Surv(time, status)~x, data = survival::aml) as.data.frame(sf)
library(survival) sf <- survfit(Surv(time, status)~x, data = survival::aml) as.data.frame(sf)
This function returns a ggplot derived from an rpsftm object showing status over time. It assumes that only a single switch in treatment occurs i.e. a patient who is randomized to control but has 25
ggatrisk(x, eval.times = NULL)
ggatrisk(x, eval.times = NULL)
x |
rpsftm object (rpsftm) |
eval.times |
- vector of times to evaluate at risk status for. Default is all event and censoring times. |
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm::rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggatrisk(imm.fit)
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm::rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggatrisk(imm.fit)
This function returns a ggplot derived from an rpsftm object showing 3 survival curves. Observed survival for experimental and control arm. Latent survival time for control arm.
ggcfact(x, incidence = FALSE)
ggcfact(x, incidence = FALSE)
x |
rpsftm object (rpsftm) |
incidence |
TRUE or FALSE (should survival or 1-survival be plotted) |
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm::rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggcfact(imm.fit)
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm::rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggcfact(imm.fit)
This function returns a ggplot derived from an rpsftm object showing hazard ratio and 95 percent CI for each psi tested in the g-estimation. A flat line suggests that there is no impact of switching on the results. A sloped line indicates that switching does affect the results.
ggdiscount(x)
ggdiscount(x)
x |
rpsftm object (rpsftm) |
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm::rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggdiscount(imm.fit)
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm::rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggdiscount(imm.fit)
This function returns a ggplot derived from an rpsftm object showing exposure to randomized and switch treatment over time. It assumes that only a single switch in treatment occurs i.e. a patient who is randomized to control but has 25 percents exposure to experimental is assumed to have switched at 0.75 times the event time.
ggexposure(x)
ggexposure(x)
x |
rpsftm object (rpsftm) |
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggexposure(imm.fit)
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggexposure(imm.fit)
This function returns a ggplot derived from an rpsftm object showing latent survival time for experimental and control arms. If converged then the two latent survival curves should overlap.
gglatent(x, incidence = FALSE)
gglatent(x, incidence = FALSE)
x |
rpsftm object (rpsftm) |
incidence |
TRUE or FALSE (should survival or 1-survival be plotted) |
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) gglatent(imm.fit)
# use data included in rpsftm package immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) gglatent(imm.fit)
This function returns a ggplot derived from an rpsftm object showing psi vs test statistic. In case of convergence should see a unique solution.
ggpsi(x)
ggpsi(x)
x |
rpsftm object (rpsftm) |
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggpsi(imm.fit)
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) ggpsi(imm.fit)
This function returns a data frame containing following variables derived from an rpsftm object. It assumes that only a single switch in treatment occurs i.e. a patient who is randomized to control but has 25
.arm - 0 or 1 - randomized arm
Arm - "Randomized to Control" or "Randomized to Experimental"
Time - time that status applies for
Status - one of "Event", "Censored", "At risk on Control", "At risk on Experimental"
Count - count of patients in this status at this time.
Percent - based on total number of patients in arm.
rpsftm.atrisk(x, eval.times = NULL)
rpsftm.atrisk(x, eval.times = NULL)
x |
rpsftm object (rpsftm) |
eval.times |
- vector of times to evaluate at risk status for. Default is all event and censoring times. |
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) rpsftm.atrisk(imm.fit, eval.times = c(0, 1, 2, 3))
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) rpsftm.atrisk(imm.fit, eval.times = c(0, 1, 2, 3))
This function fits a cox model to an rpsftm object. It estimates a hazard ratio for the comparison of experimental observed time compared to control latent time. In addition the variance of the treatment coefficient is inflated based on the test used in g-estimation. Any strata included in rpsftm call are used in the cox model.
rpsftm.coxph(x)
rpsftm.coxph(x)
x |
rpsftm object (rpsftm) |
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) rpsftm.coxph(imm.fit)
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) rpsftm.coxph(imm.fit)
This function refits an rpsftm object with a specific weight applied to control arm efficacy. It is a short cut to recalling rpsftm with same parameters and varying the treat_modifier parameter.
rpsftm.refit(x, k)
rpsftm.refit(x, k)
x |
rpsftm object (rpsftm) |
k |
weight to be applied in the control arm for treatment effect. Single number. |
See also documentation for rpsftm call treat_modifier= value.
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) rpsftm.refit(imm.fit, k = 0.7) rpsftm.refit(imm.fit, k = 1.3)
# use data included in rpsftm package library(rpsftm) immdef <- rpsftm::immdef immdef$rx <- with(immdef, 1 - xoyrs/progyrs) # fit the model imm.fit <- rpsftm(Surv(progyrs, prog) ~ rand(imm, rx), data=immdef, censor_time=censyrs) rpsftm.refit(imm.fit, k = 0.7) rpsftm.refit(imm.fit, k = 1.3)
The package extends the rpsftm package with some useful default reports and functions to facilitate sensitivity analysis. Covering descriptive, diagnostic and reporting aspects. All the functions are designed to take an rpsftm object (see rpstm::rpsftm() for details on creation) as an argument. The descriptive functions do not actually require an rspft model to be fit but rather just use it as a convenient way to store information about switching alongside survival.
The following functions are then used for descriptive analysis: * ggexposure: ggexposure(x). This function plots a single line per patient showing exposure prior to event or censoring. * ggatrisk: ggatrisk(x). This function plots at risk on treatments. * rpsftm.atrisk: rpstm.atrisk(x, eval.times). This function returns n and * ggdiscount: ggdiscount(x). This function plots hypothetical results from removing switch treatment from control arm.
The following functions are used for diagnostics: * ggpsi: ggpsi(x). This function plots psi vs Z(psi) to assess a unique solution. * gglatent: gglatent(x). This function plots the latent survival time to assess if balanced.
The following functions are used for reporting: * rpsftm.coxph: rpsftm.coxph(x). This function compares observed experimental and latent control arms with a cox model. It inflates the variance to account for the g-estimation step and correct the CI limits.
The following functions are used for sensitivity analysis of the common treatment effect: * rpsftm.refit: rpsftm.refit(x, k). This function refits an rpsftm model varying the treat_modifier parameter. Allowing sensitivities to the common treatment effect assumption.
The following functions are utilities that may have further use elsewhere and do not take an rpsftm() object as a parameter: * as.data.frame.survfit: as.data.frame.survfit(x). For a given survfit() object returns KM estimates and strata in a dataframe.