inst/doc/A500-HierarchicalBayesianResponse.R

## ----message=FALSE------------------------------------------------------------
library(trialr)

## ---- results = "hide"--------------------------------------------------------
fit <- stan_hierarchical_response_thall(
  group_responses = c(0, 0, 1, 3, 5, 0, 1, 2, 0, 0), 
  group_sizes = c(0, 2 ,1, 7, 5, 0, 2, 3, 1, 0), 
  mu_mean = -1.3863,
  mu_sd = sqrt(1 / 0.1),
  tau_alpha = 2,
  tau_beta = 20)

## -----------------------------------------------------------------------------
fit

## -----------------------------------------------------------------------------
knitr::kable(rstan::summary(fit, par = 'prob_response')$summary, digits = 3)

## -----------------------------------------------------------------------------
colMeans(as.data.frame(fit, pars = 'prob_response') > 0.3)

## ---- message = FALSE, fig.width = 7, fig.height = 7, fig.cap = "Prob(Response | D) in subgroup 3"----
library(ggplot2)
library(rstan)
library(dplyr)

plot(fit, pars = 'prob_response') + 
  geom_vline(xintercept = 0.3, col = 'orange', linetype = 'dashed') +
  labs(title = 'Partially-pooled analysis of response rate in 10 sarcoma subtypes')

Try the trialr package in your browser

Any scripts or data that you put into this service are public.

trialr documentation built on April 1, 2023, 12:03 a.m.