Introduction

In the R package pfDesign, we implement functions for the design and analysis of adaptive platform trials. The package is currently available on GitHub, and can be installed in R as follows:

require(devtools)
install_github("olssol/pfDesign")

After installation, the package can be loaded in R as follows:

require(pfDesign)

Major Function

The major function provided in pfDesign is pdFilter, which implements a particle filter algorithm for posterior sampling with a TEA prior. The function is defined as follows:

pdFilter(vec_y, vec_interval, nsmps = 5000, epsilons = 1, ...)

The main parameters for pdFilter are

  1. vec_y: Vector of binary outcomes
  2. vec_interval: Vector of interval indices
  3. epsillon: Mixture proportions $\epsilon$
  4. nsmps: Number of posterior samples

Example

The following is an example for applying the function pdFilter to obtain posterior samples. In the example, we set $\epsilon_k \equiv 0.5$, and create two intervals, split at day $100$.

## load example data in  pfDesign
data(ex_dta)

## create time intervals based on enrollment time
vec_interval <- as.numeric(cut(ex_dta$Enroll_Time,
                               breaks = c(-Inf, 100, Inf)))

## binary outcome
vec_y <- ex_dta$Outcome

## get posterior samples
post_smps <- pdFilter(vec_y,
                      vec_interval,
                      nsmps = 5000,
                      epsilons = 0.5)

The results are returned as a data.frame in post_smps. The following code generates the density plots for the posterior samples after interval 1 and 2.

r post_smps$interval <- as.factor(post_smps$interval) ggplot(data = post_smps, aes(x = theta, group = interval)) + stat_density(aes(color = interval), position = "identity", geom = "line", adjust = 1) + theme_bw()r



olssol/pfDesign documentation built on March 27, 2022, 4:30 p.m.