SafetySignalDetection.jl
This package implements Bayesian safety signal detection as proposed by Brock et al. (2023) using the Turing.jl framework.
Installation
Install this package with:
using Pkg
Pkg.add("SafetySignalDetection")
Getting started
Please have a look at the Introduction vignette to get started.
API
SafetySignalDetection.blinded_analysis_model
— MethodBlinded Analysis Model
This Turing model is used to generate posterior samples of the adverse event probabilities pi_exp
in the experimental arm and pi_ctrl
in the control arm given a blinded analysis of a trial with exp_proportion
ratio of experimental arm patients relative to all patients.
blindedanalysismodel( y::Vector{Bool}, time::Vector{Float64}, priorexp::Distribution, priorctrl::Distribution, exp_proportion::Float64)
SafetySignalDetection.blinded_analysis_samples
— MethodBlinded Analysis Posterior Samples Generation
This function wraps the Turing model blinded_analysis_model
and runs it for a data frame df
with: - y
: Bool
(did the adverse event occur?) - time
: Float64
(time until adverse event or until last treatment or follow up)
Note that arguments for the number of samples per chain and the number of chains have to be passed as well.
It returns a DataFrame
with the posterior samples for pi_exp
and pi_ctrl
.
SafetySignalDetection.fit_beta_mixture
— MethodFit a beta mixture to a vector of prior samples
This function returns a beta mixture of n_components
components approximating the distribution of the sample vector x
.
SafetySignalDetection.meta_analysis_model
— MethodMeta Analysis Model
This Turing model is used to generate posterior samples of the parameters a
and b
.
metaanalysismodel( y::Vector{Bool}, time::Vector{Float64}, trialindex::Vector{Int64}, priora::Distribution, priorb::Distribution)
SafetySignalDetection.meta_analytic_samples
— MethodMeta Analytic Prior Samples Generation
This function wraps the Turing model meta_analysis_model
and runs it for a data frame df
with: - y
: Bool
(did the adverse event occur?) - time
: Float64
(time until adverse event or until last treatment or follow up) - trialindex
: Int64
(index of trials, starting from 1 and consecutively numbered)
meta_analytic_samples(
df::DataFrame,
prior_a::Distribution,
prior_b::Distribution,
args...
)
Note that arguments for the number of samples per chain and the number of chains have to be passed as well.
It returns an array with the samples from the meta analytic prior (MAP).
- Brock, K.; Chen, C.; Ho, S.; Fuller, G.; Woolfolk, J.; Mcshea, C. and Penard, N. (2023). A Bayesian method for safety signal detection in ongoing blinded randomised controlled trials. Pharmaceutical Statistics 22, 378–395.