knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

library(tidyverse)
library(knitr)
library(kableExtra)

crmReporter

The crmReporter package is designed to provide a simple interface between crmPack (and other MCMC packages) and the tidyverse and to augment the reporting facilities provided by crmPack, coda, runjags and other packages relating to MCMC simulation.

Installation

crmReporter is available from GitHub. To install it, use

devtools::install_github("PuzzledFace/crmReporter")

Creating tidy data

Creating tidy data with crmReporter is simple: use the tidy() verb. Tidy works with mcmcs, mcmc.lists, runjagss and runjags.lists.

library(crmReporter)

data("oCRMPosteriorShort")
x <- oCRMPosteriorShort %>% tidy()
x %>% head()

You can use the output from tidy() as input to other crmReporter functions or to your own code built within the Tidyverse. Here are some sample outputs from crmReporter functions. They all use data from the first example study in the original O'Quigley paper.

data("oQuigleyPatientData")
patientSummary <- patientSummary(oQuigleyPatientData)

patientSummary %>% 
  kable(col.names=c("Dose", "Treated", "Evaluable", "No Tox", "DLT")) %>% 
  add_header_above(c(" "=1, "Number of patients"=2, "Status"=2))

subjectGraph(oQuigleyPatientData, showCohort=FALSE) + labs(title="Patient allocations and toxicity status")
allocationPlot(oQuigleyPatientData, doseGrid=1:6) + labs(title="Patient toxicity status by dose")

data("oQuigleyPosterior")
x <- oQuigleyPosterior %>% tidy() %>% augmentOQuigleyData() %>% filter(Parameter == "Prob")
summary <- createDoseSummary(x)
patientSummary %>% 
  right_join(summary, by="Dose") %>% 
  select(Dose, Treated, Evaluable, None, Tox, Mean, Q1:Q5) %>% 
  replace(is.na(.), 0) %>%
  kable(
    digits=2,
    col.names=c("Dose", "Treated", "Evaluable", "No Tox", "Tox", "Mean", "5%", "10%", "Median", "90%", "95%")
  ) %>%
  add_header_above(c(" "=1, "Patients"=4, " "=1, "Quantiles"=5)) %>%
  add_header_above(c(" "=5, "p(Tox)"=6))
x <- oQuigleyPosterior %>% tidy() %>% augmentOQuigleyData()
y <- x %>% filter(Parameter == "Prob")
y <- createDoseSummary(y)
doseToxicityGraph(y, targetTox=0.20, pivot=TRUE) + labs(title="Posterior dose-toxicity curve")
posteriorPlot(x, recDose=2) + labs(title="Posterior densities for p(Tox | Dose)")


PuzzledFace/crmReporter documentation built on June 21, 2020, 12:52 a.m.