diff --git a/docs/make.jl b/docs/make.jl index 06ef09f..3ead2ec 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -15,6 +15,7 @@ makedocs( sitename = "SafetySignalDetection", format = Documenter.HTML( assets = String["assets/citations.css"], + size_threshold = nothing ), modules = [SafetySignalDetection], pages = [ diff --git a/docs/src/introduction.md b/docs/src/introduction.md index bf66600..a3bf067 100644 --- a/docs/src/introduction.md +++ b/docs/src/introduction.md @@ -12,7 +12,7 @@ Note that: - The column `time` needs to be a `Float64` (time until adverse event or until last treatment or follow up). - The column `trialindex` needs to be `Int64` (index of historical trials, starting from 1 and consecutively numbered). -```julia +```@example 1 using CSV using DataFrames using SafetySignalDetection @@ -43,13 +43,14 @@ Note: - The number of samples (e.g. 10,000) and the number of threads (1) need to be passed as integers. Otherwise the call will fail. - We don't need to discard a burn in period now because the NUTS sampler is used internally and is discarding a burn in automatically already. -```julia +```@example 1 using Distributions prior_a = Beta(1 / 3, 1 / 3) prior_b = Beta(5, 5) map_samples = meta_analytic_samples(df, prior_a, prior_b, 10_000, 1) +map_samples[1:5] ``` The resulting $\pi^{*}$ samples in `map_samples` are from the meta-analytic prior for the adverse event rate per unit of time in the control arm in the ongoing blinded trial. @@ -63,7 +64,7 @@ Internally, the classic Expectation Maximization (EM) algorithm is used. We can check the approximation graphically by overlaying the resulting probability density function with the samples histogram. -```julia +```@example 1 using Plots map_approx = fit_beta_mixture(map_samples, 2) @@ -82,7 +83,7 @@ The important new ingredients here are: - The prior on the experimental adverse event rate. This can be uninformative, or weakly informative using a diluted background rate distribution. - The proportion of patients in the experimental treatment arm. -```julia +```@example 1 prior_exp = Beta(1, 1) prior_ctrl = map_approx exp_proportion = 0.5 @@ -92,19 +93,20 @@ df_current = DataFrame(CSV.File(csv_current_path)) df_current.y = map(x -> x == 1, df_current.y) result = blinded_analysis_samples(df_current, prior_exp, prior_ctrl, exp_proportion, 10_000, 1) +first(result, 5) ``` ## Summary We can now e.g. look at the posterior probability that the rate in the experimental arm, $\pi_E$, is larger than the event rate in the control arm, $\pi_C$. -```julia +```@example 1 mean(result[!, :pi_exp] .> result[!, :pi_ctrl]) ``` We can also create corresponding plots. -```julia +```@example 1 stephist(result[!, :pi_exp], label = "experimental arm", norm = :pdf) stephist!(result[!, :pi_ctrl], label = "control arm", norm = :pdf) ```