knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
You can use devtools::install_github()
to get the package from GitHub:
install.packages("devtools") library(devtools) install_github("dominicmagirr/modestWLRT")
library(dplyr) library(ggplot2) library(modestWLRT)
library(dplyr) library(ggplot2) devtools::load_all("..")
You can use the function delayed_effect_sim
to simulate an example data set from a 2-arm RCT. Survival times on the control arm are exponentially distributed with median med_c
. Survival times on the experimental arm follow a 2-piece exponential distibution: from time zero up to time delay
the event rate is rate_e_1
; thereafter the event rate is rate_e_2
. Patient recruitment times follow a simple power distribution:
pr(recruited before t) = (t / rec_period
)^rec_power
, for t in (0, rec_period
).
Data cut-off happens at time max_cal_t
, and any patients still alive have their survival time censored.
example_data = delayed_effect_sim(n_c = 10, n_e = 10, rec_period = 12, rec_power = 1, med_c = 15, rate_e_1 = log(2) / 15, rate_e_2 = 0.03, delay = 6, max_cal_t = 36) example_data
The function get_risk_table
takes a data frame produced from delayed_effect_sim
(or a data frame of the same form) and turns it into a risk table. This tells you how many patients were at risk / had an event / censored on each arm, at each event time.
example_risk_table = get_risk_table(example_data) example_risk_table
From the risk table, you can calculate the scores / weights from a modestWLRT. The argument delay
is used to specify how long the scores are kept constant. See the paper
http://arxiv.org/abs/1807.11097
for details.
modest_weights = add_weights(example_risk_table, method = "fixed_c", delay = 12, plot_weights = TRUE)
modest_weights$risk_table
modest_weights$p
Given the risk table with the corresponding weights, it is simple to calculate the standardized weighted logrank statistic. Larger values of Z correspond to longer survival times on the experimental arm.
get_zs(modest_weights)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.