Citation
-
Source: inst/CITATION
+
Source: inst/CITATION
Weber S, Li Y, Seaman JW, Kakizume T, Schmidli H (2021).
“Applying Meta-Analytic-Predictive Priors with the R Bayesian Evidence Synthesis Tools.”
diff --git a/news/index.html b/news/index.html
index bd82944..a9e9a31 100644
--- a/news/index.html
+++ b/news/index.html
@@ -38,11 +38,11 @@
-
RBesT 1.8-1 - January 20th, 2025
+
RBesT 1.8-1 - January 20th, 2025
CRAN release: 2025-01-21
Bugfixes
- Fixed an issue with the
ess
function for beta and gamma mixtures when used inside of lapply
or sapply
.
diff --git a/pkgdown.yml b/pkgdown.yml
index 7dac63a..22d0f6d 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -8,7 +8,7 @@ articles:
articles/PoS_codata: PoS_codata.html
articles/PoS_interim: PoS_interim.html
articles/variances_MAP: variances_MAP.html
-last_built: 2025-01-21T09:48Z
+last_built: 2025-01-21T09:56Z
urls:
reference: https://opensource.nibr.com/RBesT/reference
article: https://opensource.nibr.com/RBesT/articles
diff --git a/reference/AS.html b/reference/AS.html
index 8e69263..ad226eb 100644
--- a/reference/AS.html
+++ b/reference/AS.html
@@ -46,7 +46,7 @@
diff --git a/reference/BinaryExactCI.html b/reference/BinaryExactCI.html
index 263446b..6a75443 100644
--- a/reference/BinaryExactCI.html
+++ b/reference/BinaryExactCI.html
@@ -40,7 +40,7 @@
diff --git a/reference/Curry.html b/reference/Curry.html
index bc99a79..22ae557 100644
--- a/reference/Curry.html
+++ b/reference/Curry.html
@@ -38,7 +38,7 @@
diff --git a/reference/RBesT-package.html b/reference/RBesT-package.html
index 9da1c4b..ab01889 100644
--- a/reference/RBesT-package.html
+++ b/reference/RBesT-package.html
@@ -44,7 +44,7 @@
diff --git a/reference/SimSum.html b/reference/SimSum.html
index 8421d72..bacb317 100644
--- a/reference/SimSum.html
+++ b/reference/SimSum.html
@@ -38,7 +38,7 @@
diff --git a/reference/automixfit.html b/reference/automixfit.html
index b87dc7c..f4d4483 100644
--- a/reference/automixfit.html
+++ b/reference/automixfit.html
@@ -48,7 +48,7 @@
diff --git a/reference/chains2sample.html b/reference/chains2sample.html
index e87751b..4e5343c 100644
--- a/reference/chains2sample.html
+++ b/reference/chains2sample.html
@@ -42,7 +42,7 @@
diff --git a/reference/colVars.html b/reference/colVars.html
index 51dedf8..ddc62ab 100644
--- a/reference/colVars.html
+++ b/reference/colVars.html
@@ -38,7 +38,7 @@
diff --git a/reference/colitis.html b/reference/colitis.html
index 28908e8..563fe83 100644
--- a/reference/colitis.html
+++ b/reference/colitis.html
@@ -42,7 +42,7 @@
diff --git a/reference/crohn.html b/reference/crohn.html
index 81828b5..7091c98 100644
--- a/reference/crohn.html
+++ b/reference/crohn.html
@@ -46,7 +46,7 @@
diff --git a/reference/dBetaBinomial.html b/reference/dBetaBinomial.html
index d09a75e..c9e97b2 100644
--- a/reference/dBetaBinomial.html
+++ b/reference/dBetaBinomial.html
@@ -38,7 +38,7 @@
diff --git a/reference/decision1S.html b/reference/decision1S.html
index c65d2ac..455d3d7 100644
--- a/reference/decision1S.html
+++ b/reference/decision1S.html
@@ -40,7 +40,7 @@
diff --git a/reference/decision1S_boundary.html b/reference/decision1S_boundary.html
index 149f451..db2de2b 100644
--- a/reference/decision1S_boundary.html
+++ b/reference/decision1S_boundary.html
@@ -42,7 +42,7 @@
diff --git a/reference/decision2S.html b/reference/decision2S.html
index 34a5c99..71121b5 100644
--- a/reference/decision2S.html
+++ b/reference/decision2S.html
@@ -40,7 +40,7 @@
diff --git a/reference/decision2S_boundary.html b/reference/decision2S_boundary.html
index 6104bd5..4d3b7fc 100644
--- a/reference/decision2S_boundary.html
+++ b/reference/decision2S_boundary.html
@@ -50,7 +50,7 @@
diff --git a/reference/dlink-set.html b/reference/dlink-set.html
index 679610a..2602012 100644
--- a/reference/dlink-set.html
+++ b/reference/dlink-set.html
@@ -38,7 +38,7 @@
diff --git a/reference/ess.html b/reference/ess.html
index 9882889..fef39ea 100644
--- a/reference/ess.html
+++ b/reference/ess.html
@@ -42,7 +42,7 @@
diff --git a/reference/fill.html b/reference/fill.html
index 7ddc213..6cd499a 100644
--- a/reference/fill.html
+++ b/reference/fill.html
@@ -40,7 +40,7 @@
diff --git a/reference/forest_plot.html b/reference/forest_plot.html
index a9259a1..33dd82f 100644
--- a/reference/forest_plot.html
+++ b/reference/forest_plot.html
@@ -38,7 +38,7 @@
diff --git a/reference/gMAP.html b/reference/gMAP.html
index cbcd1e6..052f1f4 100644
--- a/reference/gMAP.html
+++ b/reference/gMAP.html
@@ -44,7 +44,7 @@
diff --git a/reference/integrate_density_log.html b/reference/integrate_density_log.html
index f3d797e..786d3fe 100644
--- a/reference/integrate_density_log.html
+++ b/reference/integrate_density_log.html
@@ -44,7 +44,7 @@
diff --git a/reference/knn.html b/reference/knn.html
index 8b51fff..d407a1d 100644
--- a/reference/knn.html
+++ b/reference/knn.html
@@ -38,7 +38,7 @@
diff --git a/reference/likelihood.html b/reference/likelihood.html
index 7b75521..f7cad8e 100644
--- a/reference/likelihood.html
+++ b/reference/likelihood.html
@@ -38,7 +38,7 @@
diff --git a/reference/lodds.html b/reference/lodds.html
index 304effc..41140c0 100644
--- a/reference/lodds.html
+++ b/reference/lodds.html
@@ -38,7 +38,7 @@
diff --git a/reference/logLik.EM.html b/reference/logLik.EM.html
index aa1fbcc..3a51b1f 100644
--- a/reference/logLik.EM.html
+++ b/reference/logLik.EM.html
@@ -38,7 +38,7 @@
diff --git a/reference/log_inv_logit.html b/reference/log_inv_logit.html
index 6ab9504..4014c64 100644
--- a/reference/log_inv_logit.html
+++ b/reference/log_inv_logit.html
@@ -38,7 +38,7 @@
diff --git a/reference/mix.html b/reference/mix.html
index 37653e3..12ed182 100644
--- a/reference/mix.html
+++ b/reference/mix.html
@@ -44,7 +44,7 @@
diff --git a/reference/mixbeta.html b/reference/mixbeta.html
index e2aba51..710fe2a 100644
--- a/reference/mixbeta.html
+++ b/reference/mixbeta.html
@@ -38,7 +38,7 @@
diff --git a/reference/mixcombine.html b/reference/mixcombine.html
index 8df3e64..a2056d5 100644
--- a/reference/mixcombine.html
+++ b/reference/mixcombine.html
@@ -38,7 +38,7 @@
diff --git a/reference/mixdiff.html b/reference/mixdiff.html
index 39dad43..737b12f 100644
--- a/reference/mixdiff.html
+++ b/reference/mixdiff.html
@@ -42,7 +42,7 @@
diff --git a/reference/mixdist3.html b/reference/mixdist3.html
index ff5efe1..e22238b 100644
--- a/reference/mixdist3.html
+++ b/reference/mixdist3.html
@@ -38,7 +38,7 @@
diff --git a/reference/mixfit.html b/reference/mixfit.html
index fbc1391..d3e0e1e 100644
--- a/reference/mixfit.html
+++ b/reference/mixfit.html
@@ -42,7 +42,7 @@
diff --git a/reference/mixgamma.html b/reference/mixgamma.html
index d7c635a..6ae7f90 100644
--- a/reference/mixgamma.html
+++ b/reference/mixgamma.html
@@ -38,7 +38,7 @@
diff --git a/reference/mixlink.html b/reference/mixlink.html
index 2c38941..ae2b014 100644
--- a/reference/mixlink.html
+++ b/reference/mixlink.html
@@ -40,7 +40,7 @@
diff --git a/reference/mixmvnorm.html b/reference/mixmvnorm.html
index 530e7fd..1177a67 100644
--- a/reference/mixmvnorm.html
+++ b/reference/mixmvnorm.html
@@ -40,7 +40,7 @@
diff --git a/reference/mixnorm.html b/reference/mixnorm.html
index 1527378..bc1a293 100644
--- a/reference/mixnorm.html
+++ b/reference/mixnorm.html
@@ -38,7 +38,7 @@
diff --git a/reference/mixplot.html b/reference/mixplot.html
index 18ec009..e2624c8 100644
--- a/reference/mixplot.html
+++ b/reference/mixplot.html
@@ -38,7 +38,7 @@
diff --git a/reference/mixstanvar.html b/reference/mixstanvar.html
index 8f09b55..956c241 100644
--- a/reference/mixstanvar.html
+++ b/reference/mixstanvar.html
@@ -42,7 +42,7 @@
diff --git a/reference/oc1S.html b/reference/oc1S.html
index db19201..fcd4633 100644
--- a/reference/oc1S.html
+++ b/reference/oc1S.html
@@ -46,7 +46,7 @@
diff --git a/reference/oc2S.html b/reference/oc2S.html
index 4203c05..8c76636 100644
--- a/reference/oc2S.html
+++ b/reference/oc2S.html
@@ -46,7 +46,7 @@
diff --git a/reference/plot.EM.html b/reference/plot.EM.html
index ec37e3e..2edd232 100644
--- a/reference/plot.EM.html
+++ b/reference/plot.EM.html
@@ -38,7 +38,7 @@
diff --git a/reference/plot.gMAP.html b/reference/plot.gMAP.html
index 018ab5e..659c95b 100644
--- a/reference/plot.gMAP.html
+++ b/reference/plot.gMAP.html
@@ -38,7 +38,7 @@
diff --git a/reference/pos1S.html b/reference/pos1S.html
index e8d013b..28dff02 100644
--- a/reference/pos1S.html
+++ b/reference/pos1S.html
@@ -46,7 +46,7 @@
diff --git a/reference/pos2S.html b/reference/pos2S.html
index fec78d3..fe43ed2 100644
--- a/reference/pos2S.html
+++ b/reference/pos2S.html
@@ -46,7 +46,7 @@
diff --git a/reference/postmix.html b/reference/postmix.html
index 0e86dde..59ba8b9 100644
--- a/reference/postmix.html
+++ b/reference/postmix.html
@@ -42,7 +42,7 @@
diff --git a/reference/preddist.html b/reference/preddist.html
index c4e685e..00ffd76 100644
--- a/reference/preddist.html
+++ b/reference/preddist.html
@@ -40,7 +40,7 @@
diff --git a/reference/predict.gMAP.html b/reference/predict.gMAP.html
index 2c44885..e54f35a 100644
--- a/reference/predict.gMAP.html
+++ b/reference/predict.gMAP.html
@@ -38,7 +38,7 @@
diff --git a/reference/robustify.html b/reference/robustify.html
index e5e6df5..c2def67 100644
--- a/reference/robustify.html
+++ b/reference/robustify.html
@@ -38,7 +38,7 @@
diff --git a/reference/support.html b/reference/support.html
index 6f91eb4..47aab07 100644
--- a/reference/support.html
+++ b/reference/support.html
@@ -38,7 +38,7 @@
diff --git a/reference/transplant.html b/reference/transplant.html
index ee0e94b..ceb9bed 100644
--- a/reference/transplant.html
+++ b/reference/transplant.html
@@ -42,7 +42,7 @@
diff --git a/reference/uniroot_int.html b/reference/uniroot_int.html
index 668853e..c79ff0e 100644
--- a/reference/uniroot_int.html
+++ b/reference/uniroot_int.html
@@ -40,7 +40,7 @@
diff --git a/search.json b/search.json
index 35db937..a477ca9 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Probability of Success with Co-Data","text":"co-data concept introduced [1]. differs use historical data approach makes use contemporary data. meta-analytic-predictive (MAP) analysis assumes historical data known time-point specyfing analysis retrospective summary available data. MAP prior combined current trial data. co-data approach extends sequential procedure meta-analytic-combined (MAC) analysis. MAC approach available data analyzed single step - , historical concurrent data combined single inference step. approaches MAP MAC yield exactly results demonstrated appendix bottom. example co-data scenario drug development simultaneous execution twin phase III trails registriation. setting, futility analysis interim analysis may take historical contemporary data account co-data approach. example discussed [1] using probability success (PoS) metric assess futility interim analysis discussed detail. key property probability success metric consideration uncertainty parameters conditional available data. contrast, conditional power (CP) calculates frequency given experemintal design successful known value parameters. example, 1-sample experiment one-sided success criterion trial successful collected data yNy_N sample size NN exceeds critical value ycy_c; recall critical value ycy_c determined success criterion, prior sample size evaluated. Assuming sampling model data p(y|θ)p(y|\\theta), CPN(θ)=∫(yN>yc)p(yN|θ)dyN. CP_N(\\theta) = \\int (y_N > y_c) \\, p(y_N|\\theta) \\, dy_N. integration data yNy_N comprises possible outcomes trial. Note start trial, CPN(θ0)CP_N(\\theta_0) type error rate conventional null hypothesis (θ=θ0\\theta=\\theta_0) CPN(θa)CP_N(\\theta_a) power trial alternative (θ=θa\\theta=\\theta_a). interim analysis sample size nIn_I, conditional power evaluated conditional observed data far (nIn_I measurements) remaining sample size (N−nIN-n_I) random distributed according p(y|θ)p(y|\\theta) θ\\theta set known value, CPN−nI(θ|ynI)=∫(ynI+yN−nI=yN>yc|ynI)p(yN−nI|θ)dyN−nI. CP_{N-n_I}(\\theta|y_{n_I}) = \\int (y_{n_I} + y_{N-n_I} = y_N > y_c|y_{n_I}) \\, p(y_{N-n_I}|\\theta) \\, dy_{N-n_I}. known value can set equal observed point estimate interim, CPN−nI(θ̂|ynI)CP_{N-n_I}(\\hat{\\theta}_{}|y_{n_I}), assumed true alternative, CPN−nI(θa|ynI)CP_{N-n_I}(\\theta_a|y_{n_I}), used plan trial. probability success contrast assigns θ\\theta distribution marginalizes conditional power distribution. absence additional trial external information distribution posterior p(θ|ynI)p(\\theta|y_{n_I}) obtained prior p(θ)p(\\theta) data collected interim, PoSI=∫CPN−nI(θ|ynI)p(θ|ynI)dθ. PoS_I = \\int CP_{N-n_I}(\\theta|y_{n_I}) \\, p(\\theta|y_{n_I}) \\, d\\theta. However, knowledge θ\\theta can refined data-sources like completed (historical) concurrent trials available, PoSI,H,...=∫CPN−nI(θ|ynI)p(θ|yI,yH,...)dθ. PoS_{,H,...} = \\int CP_{N-n_I}(\\theta|y_{n_I}) \\, p(\\theta|y_{},y_{H},...) \\, d\\theta. important note conditional power always evaluated respect trial data (prior) . Thus, additional data-sources part analysis trial. practice means probability success usually calculated trial uses non-informative priors, interim may use additional data-sources refine knowledge θ\\theta part trial analysis.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"example-data-scenario","dir":"Articles","previous_headings":"","what":"Example Data Scenario","title":"Probability of Success with Co-Data","text":"following hypothetical example [1] discussed. assumed endpoint time--event, analyzed using normal approximation log-rank statistic comparing two groups. 1:1 randomization standard error log-hazard ratio scales number events 2/Nevents2/\\sqrt{N_{events}}. implies corresponding sampling standard deviation 22, defines unit information prior used later analysis. historical data considered proof concept phase II trial. twin phase III studies event driven. trial stops whenever total 379379 events reached interim planned whenever least 150150 events occured. assumed true hazard ratio used design trial 0.80.8. Example data: remaining outline vignette first evaluate design properties trials, calculate probability success interim trial (using trial data). Next, probability success calculated using addition historical data. Subsequently, probability success trial calculated also using historical data concurrent phase III data trial B. Finally, overall probability success calculated, defined joint success trials. appendix equivalence MAP MAC approach demonstrated.","code":"trials <- data.frame( study = c(\"PoC\", \"PhII\", \"PhIII_A\", \"PhIII_B\"), deaths = c(8, 85, 162, 150), HR = c(0.7, 0.75, 0.83, 0.78), stringsAsFactors = FALSE ) ## under the normal approximation of the log-HR, the sampling sd is 2 ## such that the standard errors are sqrt(4/events) trials <- trials %>% mutate(logHR = log(HR), sem = sqrt(4 / deaths)) kable(trials, digits = 2)"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"statistical-trial-design-considerations","dir":"Articles","previous_headings":"","what":"Statistical Trial Design Considerations","title":"Probability of Success with Co-Data","text":"Key design choices: time--event endpoint phase III trials stop target # events 379 null hypothesis difference HR, θ0=1.0\\theta_0 = 1.0 one-sided α=0.025\\alpha = 0.025 alternative hypothesis assumes true HR θa=0.75\\theta_a=0.75 interim least 150 events reached Historical data: promising internal PoC promising phase II Co-data: two phase III trials run parallel ⇒\\Rightarrow phase III trial concurrent Define design choices","code":"Nev <- 379 alt_HR <- 0.75 alt_logHR <- log(alt_HR) alpha <- 0.025"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"power-calculation","dir":"Articles","previous_headings":"Statistical Trial Design Considerations","what":"Power calculation","title":"Probability of Success with Co-Data","text":"use unit information prior non-informative prior define using mean & effective sample size (ESS) specification: Define conditional power overall trial: alternative design choices result 80% power impact unit-information prior minimal can seen comparing frequentist calculation: RBesT can explore conditional power range alternatives:","code":"unit_inf <- mixnorm(c(1, 0, 1), sigma = 2, param = \"mn\") unit_inf ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 ## w 1 ## m 0 ## s 2 success_crit <- decision1S(1 - alpha, 0) ## let's print the defined criterion success_crit ## 1 sample decision function ## Conditions for acceptance: ## P(theta <= 0) > 0.975 design <- oc1S(unit_inf, Nev, success_crit, sigma = 2) design(alt_logHR) ## [1] 0.7986379 power.t.test(n = Nev, delta = -1 * alt_logHR, sd = 2, type = \"one.sample\", sig.level = 0.025, alternative = \"one.sided\") ## ## One-sample t test power calculation ## ## n = 379 ## delta = 0.2876821 ## sd = 2 ## sig.level = 0.025 ## power = 0.7976343 ## alternative = one.sided ggplot(data.frame(HR = c(0.5, 1.2)), aes(HR)) + stat_function(fun = compose(design, log)) + vline_at(c(alt_HR, 1.0), linetype = I(2)) + scale_y_continuous(breaks = seq(0, 1, by = 0.1)) + scale_x_continuous(breaks = c(alt_HR, seq(0, 1.2, by = 0.2))) + ylab(NULL) + xlab(expression(theta[a])) + ggtitle(paste(\"Power for N =\", Nev, \"events\"))"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"critical-value","dir":"Articles","previous_headings":"Statistical Trial Design Considerations","what":"Critical value","title":"Probability of Success with Co-Data","text":"critical value determines observed logHR just conclude success criterion fulfilled. can check : Ok, observing critical value, get success. Now, observe 1% worse result? success ⇒\\Rightarrow critical boundary value.","code":"design_crit <- decision1S_boundary(unit_inf, Nev, success_crit, sigma = 2) design_crit ## [1] -0.2017185 exp(design_crit) ## [1] 0.8173249 success_crit(postmix(unit_inf, m = design_crit, n = 379)) ## Using default prior reference scale 2 ## [1] 1 success_crit(postmix(unit_inf, m = design_crit + log(1.01), n = 379)) ## Using default prior reference scale 2 ## [1] 0"},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"no-use-of-historical-information","dir":"Articles","previous_headings":"PoS at interim for phase III trial A only","what":"No use of historical information","title":"Probability of Success with Co-Data","text":"Posterior treatment effect interim. trial uses non-informative prior treatment effect: Now interested PoS trial completion. prior use analysis second half given data collected far. returned function can now calculate PoS assuming distribution treatment effect. case use historical information, just interim posterior: command integrates conditional power uncertainty treatment effect defined PoSIPoS_I. conditional power operating characteristics trial coincide whenever condition observed data. key difference conditional power compared probability success assumes known value parameter interest. can seen follows: First define conditional power conditional observed data, CPN−nI(θ|ynI)CP_{N-n_I}(\\theta|y_{n_I}): conditional power assuming alternative true (HR 0.75): case uncertainty treatment effect (se=10−4se=10^-4), result agrees probability success calculation: trial B calculation :","code":"interim_A <- postmix(unit_inf, m = trials$logHR[3], se = trials$sem[3]) interim_A ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 ## w 1.0000000 ## m -0.1851865 ## s 0.1566521 interim_pos_A <- pos1S(interim_A, Nev - trials$deaths[3], success_crit, sigma = 2) interim_pos_A(interim_A) ## [1] 0.4465623 interim_oc_A <- oc1S(interim_A, Nev - trials$deaths[3], success_crit, sigma = 2) interim_oc_A(alt_logHR) ## [1] 0.708769 interim_pos_A(mixnorm(c(1, alt_logHR, 1E-4))) ## [1] 0.7087689 interim_B <- postmix(unit_inf, m = trials$logHR[4], se = trials$sem[4]) interim_pos_B <- pos1S(interim_B, Nev - trials$deaths[4], success_crit, sigma = 2) interim_pos_B(interim_B) ## [1] 0.6411569"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"use-of-historical-information---map-approach","dir":"Articles","previous_headings":"PoS at interim for phase III trial A only","what":"Use of historical information - MAP approach","title":"Probability of Success with Co-Data","text":"However, historical information can take advantage interim better informed decision. data phase III trials includes PoC phase II trial. now derive MAP prior; recall MAP prior prediction log-hazard ratio future trial: interim even knowledge available treatment effect interim data can include MAP prior: PoS posterior interim (representing historical interim data collected) : Note redefined interim_pos_A, calculates PoS phase III trial taking account final analysis use non-informative prior. trial B calculation :","code":"base <- trials[1:2, ] set.seed(342345) base_map_mc <- gMAP(cbind(logHR, sem) ~ 1 | study, family = gaussian, data = base, weights = deaths, tau.dist = \"HalfNormal\", tau.prior = 0.5, beta.prior = cbind(0, 2) ) forest_plot(base_map_mc, est = \"MAP\") base_map <- automixfit(base_map_mc) plot(base_map)$mix + xlab(expression(log(theta))) base_map ## EM for Normal Mixture Model ## Log-Likelihood = -3110.728 ## ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 comp2 comp3 ## w 0.6094510 0.2591800 0.1313691 ## m -0.2943573 -0.2783962 -0.3331379 ## s 0.2990546 0.6500315 1.1889177 interim_A_combined <- postmix(base_map, m = trials$logHR[3], se = trials$sem[3]) interim_pos_A(interim_A_combined) ## [1] 0.4850564 interim_B_combined <- postmix(base_map, m = trials$logHR[4], se = trials$sem[4]) interim_pos_B(interim_B_combined) ## [1] 0.6686476"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"use-of-historical-information---mac-approach","dir":"Articles","previous_headings":"PoS at interim for phase III trial A only","what":"Use of historical information - MAC approach","title":"Probability of Success with Co-Data","text":"However, even information can used , since phase III result trial B also available: Now trial B specific posterior interim can extract : obtain posterior (restrict first 4 columns) turn MCMC posterior sample parametric mixture finally evaluate PoS aligns published result assumption full exchangeability. trial B computations :","code":"interim_map_mc <- update(base_map_mc, data = trials) kable(fitted(interim_map_mc), digits = 3) interim_map_post <- as.matrix(interim_map_mc)[, 1:4] dim(interim_map_post) # posterior is given as matrix: iteration x parameter ## [1] 4000 4 head(interim_map_post, n = 3) ## parameters ## iterations theta[1] theta[2] theta[3] theta[4] ## [1,] 0.5793535 -0.4054789 0.1303989 -0.30952085 ## [2,] -0.3457577 -0.3818282 -0.3105840 -0.32644175 ## [3,] -0.1232030 -0.1211176 -0.1414171 -0.08166256 interim_A_allcombined <- automixfit(interim_map_post[, \"theta[3]\"]) interim_pos_A(interim_A_allcombined) ## [1] 0.5030811 interim_B_allcombined <- automixfit(interim_map_post[, \"theta[4]\"]) interim_pos_B(interim_B_allcombined) ## [1] 0.6415822"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"differential-discounting","dir":"Articles","previous_headings":"","what":"Differential discounting","title":"Probability of Success with Co-Data","text":"Differential discounting allows weight different data-sources differently. example, may assume greater heterogeneity historical data comparison twin phase III trials. Assign data historical (2) concurrent data strata (1):","code":"trials <- trials %>% mutate(stratum = c(2, 2, 1, 1)) kable(trials, digits = 2) set.seed(435345) interim_diff_map_mc <- gMAP(cbind(logHR, sem) ~ 1 | study, tau.strata = stratum, family = gaussian, data = trials, weights = deaths, tau.dist = \"HalfNormal\", tau.prior = c(0.5, 1), beta.prior = cbind(0, 2) ) interim_diff_map_post <- as.matrix(interim_diff_map_mc)[, 1:4] interim_A_diff_allcombined <- automixfit(interim_diff_map_post[, \"theta[3]\"]) interim_B_diff_allcombined <- automixfit(interim_diff_map_post[, \"theta[4]\"]) interim_pos_A(interim_A_diff_allcombined) ## [1] 0.493427 interim_pos_B(interim_B_diff_allcombined) ## [1] 0.6394128"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"pos-for-both-phase-iii-trials-being-successful","dir":"Articles","previous_headings":"","what":"PoS for both phase III trials being successful","title":"Probability of Success with Co-Data","text":"far calculated individual PoS per trial, interesting overall PoS trials successful. Recall, PoS conditional power integrated assumed true effect distribution. Hence, trial : explained, conditional power operating characerstic design conditioning already observed data: PoS integral conditional power parameter space θ\\theta representing knowledge. integral can evaluated Monte-Carlo (MC) approach PoSI=∫CPN−nI(θ|ynI)p(θ|ynI)dθ≈1S∑=1SCP(θi), PoS_I = \\int CP_{N-n_I}(\\theta|y_{n_I}) \\, p(\\theta|y_{n_I}) \\, d\\theta \\approx \\frac{1}{S} \\sum_{=1}^S CP(\\theta_i), whenever sample p(θ|ynI)p(\\theta|y_{n_I}) size SS… : MC approach calculating PoS. now considering probability trials successful perform MC integration joint density p(θA,θB|ynIA,ynIB)p(\\theta_A,\\theta_B|y_{n_{I_A}},y_{n_{I_B}}) PoS=∬CPN−nIA(θA|ynIA)CPN−nIB(θB|ynIB)p(θA,θB|ynIA,ynIB)dθAdθB≈1S∑=1SCPN−nIA(θA,|ynIA)CPN−nIB(θB,|ynIB). \\begin{aligned} PoS &= \\iint CP_{N-n_{I_A}}(\\theta_A|y_{n_{I_A}}) \\, CP_{N-n_{I_B}}(\\theta_B|y_{n_{I_B}})\\, p(\\theta_A,\\theta_B|y_{n_{I_A}},y_{n_{I_B}}) \\, d\\theta_A d\\theta_B \\\\ & \\approx \\frac{1}{S} \\sum_{=1}^S CP_{N-n_{I_A}}(\\theta_{,}|y_{n_{I_A}}) \\, CP_{N-n_{I_B}}(\\theta_{B,}|y_{n_{I_B}}). \\end{aligned} Thus need also get conditional power trial B interim… …integrate posterior samples (differential discounting case) slightly larger assuming independence: due dependence posteriors full exchangeability case ","code":"interim_pos_A(interim_A) ## [1] 0.4465623 interim_oc_A <- oc1S(interim_A, Nev - trials$deaths[3], success_crit, sigma = 2) interim_A_samp <- rmix(interim_A, 1E4) mean(interim_oc_A(interim_A_samp)) ## [1] 0.4479449 interim_oc_B <- oc1S(interim_B, Nev - trials$deaths[4], success_crit, sigma = 2) mean(interim_oc_A(interim_diff_map_post[, \"theta[3]\"]) * interim_oc_B(interim_diff_map_post[, \"theta[4]\"])) ## [1] 0.3452887 interim_pos_A(interim_A) * interim_pos_B(interim_B) ## [1] 0.2863165 cor(interim_diff_map_post[, c(\"theta[3]\", \"theta[4]\")]) ## theta[3] theta[4] ## theta[3] 1.0000000 0.3187079 ## theta[4] 0.3187079 1.0000000 mean(interim_oc_A(interim_map_post[, \"theta[3]\"]) * interim_oc_B(interim_map_post[, \"theta[4]\"])) ## [1] 0.3521087"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Probability of Success with Co-Data","text":"now calculated increasing complexity probability success various data constellations. new trials conducted whenever previous trial results positive, important take note potential selection bias. Moreover, adding historical data sources situation likely increase probability success illustrated summary preceding calculations. Phase III trial : Phase III trial B:","code":"## only interim data of trial A interim_pos_A(interim_A) ## [1] 0.4465623 ## in addition with prior historical data PoC & phase II data interim_pos_A(interim_A_combined) ## [1] 0.4850564 ## finally with the interim data of the phase III B interim_pos_A(interim_A_allcombined) ## [1] 0.5030811 ## only interim data of trial B interim_pos_B(interim_B) ## [1] 0.6411569 ## in addition with prior historical data PoC & phase II data interim_pos_B(interim_B_combined) ## [1] 0.6686476 ## finally with the interim data of the phase III A interim_pos_B(interim_B_allcombined) ## [1] 0.6415822"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"appendix-map-and-mac-equivalence","dir":"Articles","previous_headings":"","what":"Appendix: MAP and MAC equivalence","title":"Probability of Success with Co-Data","text":"preceeding sections used MAP MAC equivalence already. proof equivalence presented reference [2]. formal deriavtion shown end section MAP MAC provide exact results, difference sequential vs joint analysis (see also [2]): MAP: Summarize historical information MAP update MAP trial result (MCMC, postmix). MAC: Directly summarize historical information trial result single step (MCMC data). two results using MAP MAC line . reason MAP approach used historical data phase III trial interim data . contrast, MAC approach used historical data interim phase III data trials. show equivalence need align mismatch used data. Run gMAP base data produce large MCMC sample (10 chains) get high precision. Force accurate fit 5 components: Now, combine MAP prior (representing historical knowledge) interim data trial : Run respective MAC analysis (thus need historical data + phase III trial, excluding phase III B data): turn MCMC posterior sample parametric mixture Now let’s overlay two posterior’s PoS essentially ","code":"base_map_mc_2 <- gMAP(cbind(logHR, sem) ~ 1 | study, family = gaussian, data = base, weights = deaths, tau.dist = \"HalfNormal\", tau.prior = 0.5, beta.prior = cbind(0, 2), chains = ifelse(is_CRAN, 2, 20) ) base_map_2 <- mixfit(base_map_mc_2, Nc = 5) base_map_2 ## EM for Normal Mixture Model ## Log-Likelihood = -15088.42 ## ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 comp2 comp3 comp4 comp5 ## w 0.40929935 0.20586574 0.18866513 0.12833707 0.06783271 ## m -0.28173830 -0.64782890 0.06087094 0.16129924 -1.05921673 ## s 0.22707579 0.32358363 0.33140706 0.86765455 0.73553054 interim_A_combined_2 <- postmix(base_map_2, m = trials$logHR[3], se = trials$sem[3]) interim_map_mc_2 <- update(base_map_mc_2, data = trials[-4, ]) ## Warning: There were 3 divergent transitions after warmup. See ## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup ## to find out why this is a problem and how to eliminate them. ## Warning: Examine the pairs() plot to diagnose sampling problems ## Warning in gMAP(formula = cbind(logHR, sem) ~ 1 | study, family = gaussian, : In total 3 divergent transitions occured during the sampling phase. ## Please consider increasing adapt_delta closer to 1 with the following command prior to gMAP: ## options(RBesT.MC.control=list(adapt_delta=0.999)) interim_map_post_2 <- as.matrix(interim_map_mc_2)[, 1:3] interim_A_allcombined_2 <- mixfit(interim_map_post_2[, \"theta[3]\"], Nc = 5) interim_A_allcombined_2 ## EM for Normal Mixture Model ## Log-Likelihood = 10763.73 ## ## Univariate normal mixture ## Mixture Components: ## comp1 comp2 comp3 comp4 comp5 ## w 0.22608509 0.22287087 0.22104424 0.19134605 0.13865375 ## m -0.22358073 -0.31478209 -0.11546035 -0.32415990 -0.01378153 ## s 0.05767847 0.12976158 0.06117267 0.07871764 0.09025686 ggplot(data.frame(logHR = c(-0.8, 0.25)), aes(logHR)) + stat_function(fun = dmix, args = list(mix = interim_A_combined_2), aes(linetype = \"MAP\")) + stat_function(fun = dmix, args = list(mix = interim_A_allcombined_2), aes(linetype = \"MAC\")) + scale_linetype_discrete(\"Analysis\") + ggtitle(\"Posterior log hazard of phase III A trial at interim\") interim_pos_A(interim_A_combined_2) ## [1] 0.489214 interim_pos_A(interim_A_allcombined_2) ## [1] 0.4943454"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"formal-map-and-mac-equivalence","dir":"Articles","previous_headings":"Appendix: MAP and MAC equivalence","what":"Formal MAP and MAC equivalence","title":"Probability of Success with Co-Data","text":"stated equivalence requires posterior trial specific parameter p(θ⋆|y⋆,yH),p(\\theta_\\star|y_\\star,y_H), conditional trial specific data y⋆y_\\starand historical data yHy_H (MAC approach, joint use yH,y⋆y_H,y_\\star), equivalent obtaining MAP prior p(θ⋆|yH)p(\\theta_\\star|y_H) based historical data analyzing new trial prior. p(θ⋆|y⋆,yH)∝p(θ⋆,θH|y⋆,yH)∝p(y⋆,yH|θ⋆,θH)p(θ⋆,θH)=p(y⋆|θ⋆)p(yH|θH)p(θ⋆,θH)∝p(y⋆|θ⋆)p(θ⋆,θH|yH)∝p(y⋆|θ⋆)p(θ⋆|yH) \\begin{aligned} p(\\theta_\\star|y_\\star,y_H) &\\propto p(\\theta_\\star,\\theta_H|y_\\star,y_H) \\\\ &\\propto p(y_\\star,y_H|\\theta_\\star,\\theta_H) \\, p(\\theta_\\star,\\theta_H) \\\\ &= p(y_\\star|\\theta_\\star) \\, p(y_H|\\theta_H) \\, p(\\theta_\\star,\\theta_H) \\\\ &\\propto p(y_\\star|\\theta_\\star) \\, p(\\theta_\\star,\\theta_H|y_H) \\\\ &\\propto p(y_\\star|\\theta_\\star) \\, p(\\theta_\\star|y_H) \\end{aligned} equivalence holds use meta-analytic model.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Probability of Success with Co-Data","text":"[1] Neuenschwander, B., Roychoudhury, S., & Schmidli, H. (2016). Use Co-Data Clinical Trials. Statistics Biopharmaceutical Research, 8(3), 345-354. [2] 1. Schmidli H, Gsteiger S, Roychoudhury S, O’Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics. 2014;70(4):1023-1032.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"r-session-info","dir":"Articles","previous_headings":"","what":"R Session Info","title":"Probability of Success with Co-Data","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] purrr_1.0.2 dplyr_1.1.4 bayesplot_1.11.1 ggplot2_3.5.1 ## [5] knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 rlang_1.1.5 ## [25] munsell_0.5.1 withr_3.0.2 cachem_1.1.0 ## [28] yaml_2.3.10 StanHeaders_2.32.10 parallel_4.4.2 ## [31] tools_4.4.2 rstan_2.32.6 inline_0.3.21 ## [34] reshape2_1.4.4 rstantools_2.4.0 checkmate_2.3.2 ## [37] colorspace_2.1-1 assertthat_0.2.1 posterior_1.6.0 ## [40] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [43] stats4_4.4.2 lifecycle_1.0.4 stringr_1.5.1 ## [46] fs_1.6.5 htmlwidgets_1.6.4 ragg_1.3.3 ## [49] pkgconfig_2.0.3 desc_1.4.3 pkgdown_2.1.1 ## [52] RcppParallel_5.1.9 pillar_1.10.1 bslib_0.8.0 ## [55] gtable_0.3.6 loo_2.8.0 glue_1.8.0 ## [58] Rcpp_1.0.14 systemfonts_1.2.0 xfun_0.50 ## [61] tibble_3.2.1 tidyselect_1.2.1 farver_2.1.2 ## [64] htmltools_0.5.8.1 labeling_0.4.3 rmarkdown_2.29 ## [67] compiler_4.4.2 distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_interim.html","id":"r-session-info","dir":"Articles","previous_headings":"","what":"R Session Info","title":"Probability of Success at an Interim Analysis","text":"","code":"## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] dplyr_1.1.4 scales_1.3.0 ggplot2_3.5.1 knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] sass_0.4.9 generics_0.1.3 digest_0.6.37 ## [4] magrittr_2.0.3 evaluate_1.0.3 grid_4.4.2 ## [7] mvtnorm_1.3-3 fastmap_1.2.0 jsonlite_1.8.9 ## [10] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [13] gridExtra_2.3 QuickJSR_1.5.1 codetools_0.2-20 ## [16] textshaping_0.4.1 jquerylib_0.1.4 abind_1.4-8 ## [19] cli_3.6.3 rlang_1.1.5 munsell_0.5.1 ## [22] withr_3.0.2 cachem_1.1.0 yaml_2.3.10 ## [25] StanHeaders_2.32.10 parallel_4.4.2 tools_4.4.2 ## [28] rstan_2.32.6 inline_0.3.21 rstantools_2.4.0 ## [31] checkmate_2.3.2 colorspace_2.1-1 assertthat_0.2.1 ## [34] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [37] stats4_4.4.2 lifecycle_1.0.4 fs_1.6.5 ## [40] htmlwidgets_1.6.4 ragg_1.3.3 pkgconfig_2.0.3 ## [43] desc_1.4.3 pkgdown_2.1.1 RcppParallel_5.1.9 ## [46] pillar_1.10.1 bslib_0.8.0 gtable_0.3.6 ## [49] loo_2.8.0 glue_1.8.0 Rcpp_1.0.14 ## [52] systemfonts_1.2.0 xfun_0.50 tibble_3.2.1 ## [55] tidyselect_1.2.1 farver_2.1.2 htmltools_0.5.8.1 ## [58] labeling_0.4.3 rmarkdown_2.29 compiler_4.4.2"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Customizing RBesT plots","text":"vignette demonstrates work forest plot provided RBesT package. show modify default plot , advanced users, extract data ggplot object create new plot scratch. Finally recreate plots case study presented training materials. general information plotting R, recommend following resources: bayesplot - library RBesT plotting functionality built ggplot2 - powerful library graphics R R Cookbook - Graphs - general reference R graphics R","code":"# Load required libraries library(RBesT) library(ggplot2) library(dplyr) ## ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ## ## filter, lag ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union library(tidyr) library(bayesplot) ## This is bayesplot version 1.11.1 ## - Online documentation and vignettes at mc-stan.org/bayesplot ## - bayesplot theme set to bayesplot::theme_default() ## * Does _not_ affect other ggplot2 plots ## * See ?bayesplot_theme_set for details on theme setting # Default settings for bayesplot color_scheme_set(\"blue\") theme_set(theme_default(base_size = 12)) # Load example gMAP object set.seed(546346) map_crohn <- gMAP(cbind(y, y.se) ~ 1 | study, family = gaussian, data = transform(crohn, y.se = 88 / sqrt(n)), weights = n, tau.dist = \"HalfNormal\", tau.prior = 44, beta.prior = cbind(0, 88) ) print(map_crohn) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(y, y.se) ~ 1 | study, family = gaussian, ## data = transform(crohn, y.se = 88/sqrt(n)), weights = n, ## tau.dist = \"HalfNormal\", tau.prior = 44, beta.prior = cbind(0, ## 88)) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## Estimated reference scale : 88 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 14.50 9.67 1.30 12.60 38.30 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## -50.5 19.4 -94.3 -49.0 -10.7"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"forest-plot","dir":"Articles","previous_headings":"","what":"Forest plot","title":"Customizing RBesT plots","text":"default forest plot “standard” forest plot Meta-Analytic-Predictive (MAP) prior additionally summarized bottom row: can also include model-based estimates study, add legend explain different linetypes. can modify color scheme follows (refer help(color_scheme_set) full list themes): point size can modified vertical line removed:","code":"forest_plot(map_crohn) forest_plot(map_crohn, model = \"both\") + legend_move(\"right\") # preview a color scheme color_scheme_view(\"mix-blue-red\") # and now let's use it color_scheme_set(\"mix-blue-red\") forest_plot(map_crohn) color_scheme_set(\"gray\") forest_plot(map_crohn) color_scheme_set(\"blue\") forest_plot(map_crohn, size = 0.5, alpha = 0)"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"presentation-ready-plots","dir":"Articles","previous_headings":"Forest plot","what":"Presentation-ready plots","title":"Customizing RBesT plots","text":"plot used presentation document study protocol, recommended use sufficiently large font sizes (e.g. large fonts slide document) elements plot clearly visible. show simple statements can used purpose. also recommend saving plots explicitly ggsave function, allows control (hence consistency) image size. Note font size enforced requested size; small image large font size may result little space plot . image sized according golden cut (ϕ=1+52≈1.62\\phi=\\frac{1+\\sqrt5}{2} \\approx 1.62) perceived pleasing axis ratio. Png recommended image file type presentations study documents.","code":"# adjust the base font size theme_set(theme_default(base_size = 16)) forest_plot(map_crohn, model = \"both\", est = \"MAP\", size = 1) + legend_move(\"right\") + labs( title = \"Forest plot\", subtitle = \"Results of Meta-Analytic-Predictive (MAP) analysis\", caption = \"Plot shows point estimates (posterior medians) with 95% intervals\" ) ggsave(\"plot1.png\", last_plot(), width = 1.62 * 2.78, height = 2.78, unit = \"in\") # too small for the chosen font size ggsave(\"plot2.png\", last_plot(), width = 1.62 * 5.56, height = 5.56, unit = \"in\") # fits a single ppt slide quite well"},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"extract-data-from-a-ggplot-object","dir":"Articles","previous_headings":"Advanced topics","what":"Extract data from a ggplot object","title":"Customizing RBesT plots","text":"situations, desired modifications plot provided RBesT may possible given returned ggplot object. truly tailored plot desired, user must extract data object create graph scratch using ggplot functions. Recall original forest plot: Suppose wish use different symbols meta/stratified point estimates different linestyle vertical line. tailored plot can created follows.","code":"# Extract the data from the returned object fp_data <- forest_plot(map_crohn)$data print(fp_data, digits = 2) ## mean sem median low up study model ## Gastr06 -51 10.2 -51 -71 -30.9 Gastr06 stratified ## AIMed07 -49 6.8 -49 -62 -35.6 AIMed07 stratified ## NEJM07 -36 4.9 -36 -46 -26.5 NEJM07 stratified ## Gastr01a -47 19.7 -47 -86 -8.4 Gastr01a stratified ## APhTh04 -90 17.6 -90 -124 -55.5 APhTh04 stratified ## Gastr01b -54 11.6 -54 -77 -31.4 Gastr01b stratified ## theta_resp_pred -50 19.4 -49 -94 -10.7 MAP meta ## theta_resp -50 8.6 -49 -69 -34.2 Mean meta # Use a two-component map mixture to compute the vertical line location map_mix <- mixfit(map_crohn, Nc = 2) # Finally compose a ggplot call for the desired graph ggplot(fp_data, aes(x = study, y = median, ymin = low, ymax = up, linetype = model, shape = model)) + geom_pointrange(size = 0.7, position = position_dodge(width = 0.5)) + geom_hline(yintercept = qmix(map_mix, 0.5), linetype = 3, alpha = 0.5) + coord_flip() + theme_bw(base_size = 12) + theme(legend.position = \"None\") + labs(x = \"\", y = \"Response\", title = \"Modified forest plot\")"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"design-plots-a-clinical-trial","dir":"Articles","previous_headings":"Advanced topics","what":"Design plots a clinical trial","title":"Customizing RBesT plots","text":"show create outcome operating characteristic plots clinical trial comparing developmental drug placebo. primary endpoint binary (event probability pp) use informative prior placebo arm event rate. experimental drug believed lower event rate, criteria study outcome hence follows: Criterion 1:Pr(ptrt/ppbo<1)>0.9Criterion 2:Pr(ptrt/ppbo<0.5)>0.5 \\begin{align*} \\textrm{Criterion 1:} \\Pr(p_{trt} / p_{pbo} < 1) &> 0.9\\\\ \\textrm{Criterion 2:} \\Pr(p_{trt} / p_{pbo} < 0.5) &> 0.5 \\end{align*} outcome success (GO) criteria satisfied, futility (STOP) neither satisfied, indeterminate one satisfied. now create plot shows study conclusion, given combination outcomes two treatment arms. can also use design functions already derived (design_suc design_fut) compute operating characteristics.","code":"# Define prior distributions prior_pbo <- mixbeta(inf1 = c(0.60, 19, 29), inf2 = c(0.30, 4, 5), rob = c(0.10, 1, 1)) prior_trt <- mixbeta(c(1, 1 / 3, 1 / 3)) # Study sample size n_trt <- 50 n_pbo <- 20 # Create decision rules and designs to represent success and futility success <- decision2S(pc = c(0.90, 0.50), qc = c(log(1), log(0.50)), lower.tail = TRUE, link = \"log\") futility <- decision2S(pc = c(0.10, 0.50), qc = c(log(1), log(0.50)), lower.tail = FALSE, link = \"log\") design_suc <- oc2S(prior_trt, prior_pbo, n_trt, n_pbo, success) design_fut <- oc2S(prior_trt, prior_pbo, n_trt, n_pbo, futility) crit_suc <- decision2S_boundary(prior_trt, prior_pbo, n_trt, n_pbo, success) crit_fut <- decision2S_boundary(prior_trt, prior_pbo, n_trt, n_pbo, futility) # Create a data frame that holds the outcomes for y1 (treatment) that define success and futility, # conditional on the number of events on y2 (placebo) outcomes <- data.frame(y2 = c(0:n_pbo), suc = crit_suc(0:n_pbo), fut = crit_fut(0:n_pbo), max = n_trt) outcomes$suc <- with(outcomes, ifelse(suc < 0, 0, suc)) # don't allow negative number of events # Finally put it all together in a plot. o <- 0.5 # offset ggplot(outcomes, aes(x = y2, ymin = -o, ymax = suc + o)) + geom_linerange(size = 4, colour = \"green\", alpha = 0.6) + geom_linerange(aes(ymin = suc + o, ymax = fut + o), colour = \"orange\", size = 4, alpha = 0.6) + geom_linerange(aes(ymin = fut + o, ymax = max + o), colour = \"red\", size = 4, alpha = 0.6) + annotate(\"text\", x = c(2, 14), y = c(36, 8), label = c(\"STOP\", \"GO\"), size = 10) + scale_x_continuous(breaks = seq(0, n_pbo, by = 2)) + scale_y_continuous(breaks = seq(0, n_trt, by = 4)) + labs(x = \"Events on placebo\", y = \"Events on treatment\", title = \"Study outcomes\") + coord_flip() + theme_bw(base_size = 12) ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. ## ℹ Please use `linewidth` instead. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated. # Define the grid of true event rates for which to evaluate OC p_trt <- seq(0, 0.5, length = 200) p_pbo <- c(0.35, 0.40, 0.45, 0.50) # Loop through the values for placebo and compute outcome probabilities oc_list <- lapply(p_pbo, function(x) { p_go <- design_suc(p_trt, x) p_stop <- design_fut(p_trt, x) data.frame(p_trt, p_pbo = x, Go = p_go, Stop = p_stop, Indeterminate = 1 - p_go - p_stop) }) # The above returns a list, so we bind the elements together into one data frame oc <- bind_rows(oc_list) # And convert from wide to long format oc <- gather(oc, \"Outcome\", \"Probability\", 3:5) oc$facet_text <- as.factor(paste(\"True placebo rate = \", oc$p_pbo, sep = \"\")) # Finally we are ready to plot ggplot(oc, aes(x = p_trt, y = Probability, colour = Outcome, linetype = Outcome)) + facet_wrap(~facet_text) + geom_line(size = 1) + scale_colour_manual(values = c(\"green\", \"orange\", \"red\"), name = \"Outcome\") + scale_linetype(guide = FALSE) + geom_hline(yintercept = c(0.1, 0.8), linetype = 3) + scale_y_continuous(breaks = seq(0, 1, by = 0.2)) + labs(x = \"True event rate for treatment\", y = \"Probability\", title = \"Operating Characteristics\") + theme_bw(base_size = 12) ## Warning: The `guide` argument in `scale_*()` cannot be `FALSE`. This was deprecated in ## ggplot2 3.3.4. ## ℹ Please use \"none\" instead. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated. sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] bayesplot_1.11.1 tidyr_1.3.1 dplyr_1.1.4 ggplot2_3.5.1 ## [5] knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] sass_0.4.9 generics_0.1.3 digest_0.6.37 ## [4] magrittr_2.0.3 evaluate_1.0.3 grid_4.4.2 ## [7] mvtnorm_1.3-3 fastmap_1.2.0 jsonlite_1.8.9 ## [10] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [13] gridExtra_2.3 purrr_1.0.2 QuickJSR_1.5.1 ## [16] scales_1.3.0 codetools_0.2-20 textshaping_0.4.1 ## [19] jquerylib_0.1.4 abind_1.4-8 cli_3.6.3 ## [22] crayon_1.5.3 rlang_1.1.5 munsell_0.5.1 ## [25] withr_3.0.2 cachem_1.1.0 yaml_2.3.10 ## [28] StanHeaders_2.32.10 parallel_4.4.2 tools_4.4.2 ## [31] rstan_2.32.6 inline_0.3.21 rstantools_2.4.0 ## [34] checkmate_2.3.2 colorspace_2.1-1 assertthat_0.2.1 ## [37] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [40] stats4_4.4.2 lifecycle_1.0.4 fs_1.6.5 ## [43] htmlwidgets_1.6.4 ragg_1.3.3 pkgconfig_2.0.3 ## [46] desc_1.4.3 pkgdown_2.1.1 RcppParallel_5.1.9 ## [49] pillar_1.10.1 bslib_0.8.0 gtable_0.3.6 ## [52] loo_2.8.0 glue_1.8.0 Rcpp_1.0.14 ## [55] systemfonts_1.2.0 xfun_0.50 tibble_3.2.1 ## [58] tidyselect_1.2.1 farver_2.1.2 htmltools_0.5.8.1 ## [61] labeling_0.4.3 rmarkdown_2.29 compiler_4.4.2"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting started with RBesT (binary)","text":"R Bayesian evidence synthesis Tools (RBesT) facilitate use historical information clinical trials. relevant historical information identified, RBesT supports derivation informative priors via Meta-Analytic-Predictive (MAP) approach [1] evaluation trial’s operating characteristics. MAP approach performs standard meta-analysis followed prediction control group parameter future study accounting uncertainty population mean (standard result meta-analysis) -trial heterogeneity. Therefore, RBesT can also used meta-analysis tool one simply neglects prediction part. document demonstrates RBesT can used derive historical control data prior binary endpoint. RBesT package homepage contains articles introductory material: Probability success co-data Probability success interim normal endpoint Customizing RBesT plots RBesT normal endpoint Meta-Analytic-Predictive priors variances","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"binary-responder-analysis-example","dir":"Articles","previous_headings":"","what":"Binary responder analysis example","title":"Getting started with RBesT (binary)","text":"Let’s consider Novartis Phase II study ankylosing spondylitis comparing Novartis test treatment secukinumab placebo [2]. primary efficacy endpoint percentage patients 20% response according Assessment SpondyloArthritis international Society criteria improvement (ASAS20) week 6. control group, following historical data used derive MAP prior: dataset part RBesT available loading package data frame . RBesT supports required steps design clinical trial historical information using MAP approach.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"meta-analytic-predictive-analysis","dir":"Articles","previous_headings":"Prior Derivation","what":"Meta-Analytic-Predictive Analysis","title":"Getting started with RBesT (binary)","text":"gMAP function performs meta-analysis prediction, yields MAP prior. analysis run using stochastic Markov-Chain-Monte-Carlo Stan. order make results exactly reproducible, set.seed function must called prior calling gMAP . key parameter meta-analysis -trial heterogeneity parameter τ\\tau controls amount borrowing historical information estimation population mean occur. often historical trials, prior important. binary endpoints expected response rate 20%-80% recommend conservative HalfNormal(0,1) prior default. Please refer help-page gMAP information. gMAP function returns analysis object can extract information using functions RBesT. recommend look graphical model checks provided RBesT demonstrated . important one forest plot, solid lines MAP model predictions dashed lines stratified estimates. standard forest plot without shrinkage estimates please refer forest_plot function RBesT. often raised concern Bayesian analysis choice prior. Hence sensitivity analyses may sometimes necessary. can quickly performed update function. Suppose want evaluate optimistic scenario (less -trial heterogeneity), expressed HalfNormal(0,1/2) prior τ\\tau. can rerun original analysis, modified arguments gMAP:","code":"# load R packages library(RBesT) library(ggplot2) theme_set(theme_bw()) # sets up plotting theme set.seed(34563) map_mcmc <- gMAP(cbind(r, n - r) ~ 1 | study, data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2, family = binomial ) ## Assuming default prior location for beta: 0 print(map_mcmc) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(r, n - r) ~ 1 | study, family = binomial, ## data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 0.3770 0.2170 0.0414 0.3460 0.8930 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## 0.2580 0.0842 0.1120 0.2510 0.4590 ## a graphical representation of model checks is available pl <- plot(map_mcmc) ## a number of plots are immediately defined names(pl) ## [1] \"densityThetaStar\" \"densityThetaStarLink\" \"forest_model\" ## forest plot with model estimates print(pl$forest_model) set.seed(36546) map_mcmc_sens <- update(map_mcmc, tau.prior = 1 / 2) ## Assuming default prior location for beta: 0 print(map_mcmc_sens) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(r, n - r) ~ 1 | study, family = binomial, ## data = AS, tau.dist = \"HalfNormal\", tau.prior = 1/2, beta.prior = 2) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 0.3350 0.1750 0.0416 0.3140 0.7280 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## 0.2560 0.0786 0.1200 0.2470 0.4390"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"parametric-approximation","dir":"Articles","previous_headings":"Prior Derivation","what":"Parametric Approximation","title":"Getting started with RBesT (binary)","text":"next step, MAP prior, represented numerically using large MCMC simulation sample, converted parametric representation automixfit function. function fits parametric mixture representation using expectation-maximization (EM). number mixture components best describe MAP chosen automatically. , plot function produces graphical diagnostic allows user assess whether marginal mixture density (shown black) matches well histogram MAP MCMC sample.","code":"map <- automixfit(map_mcmc) print(map) ## EM for Beta Mixture Model ## Log-Likelihood = 4523.865 ## ## Univariate beta mixture ## Mixture Components: ## comp1 comp2 ## w 0.6167463 0.3832537 ## a 19.1916387 3.5278745 ## b 57.7779318 9.3735980 plot(map)$mix"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"effective-sample-size","dir":"Articles","previous_headings":"Prior Derivation","what":"Effective Sample Size","title":"Getting started with RBesT (binary)","text":"(usual) intended use (MAP) prior reduce number control patients trial. prior can considered equivalent number experimental observations, called effective sample size (ESS) prior. can calculated RBesT ess function. noted, however, concept ESS somewhat elusive. particular, definition ESS unique multiple methods therefore implemented RBesT. default method RBesT elir approach [5] results reasonable ESS estimates. moment matching approach leads conservative (small) ESS estimates Morita [3] method tends estimates liberal (large) ESS estimates used mixtures: Morita approach uses curvature prior mode found sensitive large number mixture components. experience, realistic ESS estimate can obtained elir method method predictively consistent, see [5] details.","code":"round(ess(map, method = \"elir\")) ## default method ## [1] 37 round(ess(map, method = \"moment\")) ## [1] 26 round(ess(map, method = \"morita\")) ## [1] 63"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"robustification-of-the-map-prior","dir":"Articles","previous_headings":"Prior Derivation","what":"Robustification of the MAP Prior","title":"Getting started with RBesT (binary)","text":"Finally, recommend robustify [4] prior protects type-error inflation presence prior-data conflict, .e. future trial data strongly deviate historical control information. Adding robust mixture component reduce ESS MAP prior extent depends weight robust component. Selecting higher robust mixture weights leads greater discounting informative MAP prior vice versa. consequence robust weight controls degree influence MAP prior within final analysis. circumstances can helpful graphically illustrate relationship prior ESS function robust mixture component weight:","code":"## add a 20% non-informative mixture component map_robust <- robustify(map, weight = 0.2, mean = 1 / 2) print(map_robust) ## Univariate beta mixture ## Mixture Components: ## comp1 comp2 robust ## w 0.493397 0.306603 0.200000 ## a 19.191639 3.527875 1.000000 ## b 57.777932 9.373598 1.000000 round(ess(map_robust)) ## [1] 26 ess_weight <- data.frame(weight = seq(0.05, 0.95, by = 0.05), ess = NA) for (i in seq_along(ess_weight$weight)) { ess_weight$ess[i] <- ess(robustify(map, ess_weight$weight[i], 0.5)) } ess_weight <- rbind( ess_weight, data.frame( weight = c(0, 1), ess = c(ess(map), ess(mixbeta(c(1, 1, 1)))) ) ) ggplot(ess_weight, aes(weight, ess)) + geom_point() + geom_line() + ggtitle(\"ESS of robust MAP for varying weight of robust component\") + scale_x_continuous(breaks = seq(0, 1, by = 0.1)) + scale_y_continuous(breaks = seq(0, 40, by = 5))"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"design-evaluation","dir":"Articles","previous_headings":"","what":"Design Evaluation","title":"Getting started with RBesT (binary)","text":"Now prior can specified protocol. advantage using historical information possible reduction placebo patient group. sample size control group supplemented historical information. reduction placebo patients can large ESS MAP prior. following, compare designs different sample sizes priors control group. comparisons carried evaluating standard Frequentist operating characteristics (type-error, power). scenarios exhaustive, rather specific ones demonstrate use RBesT design evaluation.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"operating-characteristics","dir":"Articles","previous_headings":"Design Evaluation","what":"Operating Characteristics","title":"Getting started with RBesT (binary)","text":"consider 2-arm design actual Novartis trial ankylosing spondylitis [2]. trial tested 6 patients placebo control 24 patients active experimental treatment. Success declared whenever condition Pr(θactive−θcontrol>0)>0.95\\Pr(\\theta_{active} - \\theta_{control} > 0) > 0.95 met response rates θactive\\theta_{active} θcontrol\\theta_{control}. MAP prior used placebo response rate parameter. evaluate design options example. operating characteristics setup RBesT stepwise manner: Definition priors arm. Definition decision criterion using decision2S function. Specification design options oc2S function. includes overall decision function per arm prior sample size use. object step 3 used calculate operating characteristics. Note 1-sample situation respective decision1S oc1S function used instead.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"type-i-error","dir":"Articles","previous_headings":"Design Evaluation > Operating Characteristics","what":"Type I Error","title":"Getting started with RBesT (binary)","text":"type can increased compared nominal α\\alpha level case conflict trial data prior. Note, example MAP prior 95% interval 0.1 0.5. Note observing response rates greater 50% highly implausible based MAP analysis: Hence, resonable restrict response rates θ\\theta evaluate type error range plausible values:","code":"theta <- seq(0.1, 0.95, by = 0.01) uniform_prior <- mixbeta(c(1, 1, 1)) treat_prior <- mixbeta(c(1, 0.5, 1)) # prior for treatment used in trial lancet_prior <- mixbeta(c(1, 11, 32)) # prior for control used in trial decision <- decision2S(0.95, 0, lower.tail = FALSE) design_uniform <- oc2S(uniform_prior, uniform_prior, 24, 6, decision) design_classic <- oc2S(uniform_prior, uniform_prior, 24, 24, decision) design_nonrobust <- oc2S(treat_prior, map, 24, 6, decision) design_robust <- oc2S(treat_prior, map_robust, 24, 6, decision) typeI_uniform <- design_uniform(theta, theta) typeI_classic <- design_classic(theta, theta) typeI_nonrobust <- design_nonrobust(theta, theta) typeI_robust <- design_robust(theta, theta) ocI <- rbind( data.frame(theta = theta, typeI = typeI_robust, prior = \"robust\"), data.frame(theta = theta, typeI = typeI_nonrobust, prior = \"non-robust\"), data.frame(theta = theta, typeI = typeI_uniform, prior = \"uniform\"), data.frame(theta = theta, typeI = typeI_classic, prior = \"uniform 24:24\") ) ggplot(ocI, aes(theta, typeI, colour = prior)) + geom_line() + ggtitle(\"Type I Error\") summary(map) ## mean sd 2.5% 50.0% 97.5% ## 0.25857963 0.08423297 0.10808237 0.25003652 0.47028444 ggplot(ocI, aes(theta, typeI, colour = prior)) + geom_line() + ggtitle(\"Type I Error - response rate restricted to plausible range\") + coord_cartesian(xlim = c(0, 0.5))"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"power","dir":"Articles","previous_headings":"Design Evaluation > Operating Characteristics","what":"Power","title":"Getting started with RBesT (binary)","text":"power demonstrates gain using informative prior; .e. 80% power reached smaller δ\\delta values comparison design non-informative priors arms. see MAP prior one reaches greater power smaller differences δ\\delta response rate. example, δ\\delta 80% power reached can found :","code":"delta <- seq(0, 0.7, by = 0.01) mean_control <- summary(map)[\"mean\"] theta_active <- mean_control + delta theta_control <- mean_control + 0 * delta power_uniform <- design_uniform(theta_active, theta_control) power_classic <- design_classic(theta_active, theta_control) power_nonrobust <- design_nonrobust(theta_active, theta_control) power_robust <- design_robust(theta_active, theta_control) ocP <- rbind( data.frame(theta_active, theta_control, delta = delta, power = power_robust, prior = \"robust\"), data.frame(theta_active, theta_control, delta = delta, power = power_nonrobust, prior = \"non-robust\"), data.frame(theta_active, theta_control, delta = delta, power = power_uniform, prior = \"uniform\"), data.frame(theta_active, theta_control, delta = delta, power = power_classic, prior = \"uniform 24:24\") ) ggplot(ocP, aes(delta, power, colour = prior)) + geom_line() + ggtitle(\"Power\") find_delta <- function(design, theta_control, target_power) { uniroot( function(delta) { design(theta_control + delta, theta_control) - target_power }, interval = c(0, 1 - theta_control) )$root } target_effect <- data.frame( delta = c( find_delta(design_nonrobust, mean_control, 0.8), find_delta(design_classic, mean_control, 0.8), find_delta(design_robust, mean_control, 0.8), find_delta(design_uniform, mean_control, 0.8) ), prior = c(\"non-robust\", \"uniform 24:24\", \"robust\", \"uniform\") ) knitr::kable(target_effect, digits = 3)"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"data-scenarios","dir":"Articles","previous_headings":"Design Evaluation > Operating Characteristics","what":"Data Scenarios","title":"Getting started with RBesT (binary)","text":"alternative approach visualize study design non-statisticians considering data scenarios. show decisions based potential trial outcomes. information needed critical values decision criterion flips. 2-sample case means calculate decision boundary, see decision2S_boundary help information. graph shows decision always negative less 10 events treatment group. hand, non-robust prior assuming 15 events treatment group, three (less) placebo events needed success. check result, can directly evaluate decision function:","code":"## Critical values at which the decision flips are given conditional ## on the outcome of the second read-out; as we like to have this as a ## function of the treatment group outcome, we flip label 1 and 2 decision_flipped <- decision2S(0.95, 0, lower.tail = TRUE) crit_uniform <- decision2S_boundary(uniform_prior, uniform_prior, 6, 24, decision_flipped) crit_nonrobust <- decision2S_boundary(map, treat_prior, 6, 24, decision_flipped) crit_robust <- decision2S_boundary(map_robust, treat_prior, 6, 24, decision_flipped) treat_y2 <- 0:24 ## Note that -1 is returned to indicated that the decision is never 1 ocC <- rbind( data.frame(y2 = treat_y2, y1_crit = crit_robust(treat_y2), prior = \"robust\"), data.frame(y2 = treat_y2, y1_crit = crit_nonrobust(treat_y2), prior = \"non-robust\"), data.frame(y2 = treat_y2, y1_crit = crit_uniform(treat_y2), prior = \"uniform\") ) ggplot(ocC, aes(y2, y1_crit, colour = prior)) + geom_step() + ggtitle(\"Critical values y1(y2)\") ## just positive decision(postmix(treat_prior, n = 24, r = 15), postmix(map, n = 6, r = 3)) ## [1] 1 ## negative decision(postmix(treat_prior, n = 24, r = 14), postmix(map, n = 6, r = 4)) ## [1] 0"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"trial-analysis","dir":"Articles","previous_headings":"","what":"Trial Analysis","title":"Getting started with RBesT (binary)","text":"trial completed data collected, final analysis can run RBesT using postmix function. Calculations performed analytically conjugate mixture setting.","code":"r_placebo <- 1 r_treat <- 14 ## first obtain posterior distributions... post_placebo <- postmix(map_robust, r = r_placebo, n = 6) post_treat <- postmix(treat_prior, r = r_treat, n = 24) ## ...then calculate probability that the difference is smaller than ## zero prob_smaller <- pmixdiff(post_treat, post_placebo, 0, lower.tail = FALSE) prob_smaller ## [1] 0.9913233 prob_smaller > 0.95 ## [1] TRUE ## alternativley we can use the decision object decision(post_treat, post_placebo) ## [1] 1"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"references","dir":"Articles","previous_headings":"Trial Analysis","what":"References","title":"Getting started with RBesT (binary)","text":"[1] Neuenschwander B. et al., Clin Trials. 2010; 7(1):5-18 [2] Baeten D. et al., Lancet, 2013, (382), 9906, p 1705 [3] Morita S. et al., Biometrics 2008;64(2):595-602 [4] Schmidli H. et al., Biometrics 2014;70(4):1023-1032 [5] Neuenschwander B. et al., Biometrics 2020;76(2):578-587","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"r-session-info","dir":"Articles","previous_headings":"Trial Analysis","what":"R Session Info","title":"Getting started with RBesT (binary)","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] ggplot2_3.5.1 knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 rlang_1.1.5 ## [25] munsell_0.5.1 withr_3.0.2 cachem_1.1.0 ## [28] yaml_2.3.10 StanHeaders_2.32.10 parallel_4.4.2 ## [31] tools_4.4.2 rstan_2.32.6 inline_0.3.21 ## [34] reshape2_1.4.4 rstantools_2.4.0 checkmate_2.3.2 ## [37] dplyr_1.1.4 colorspace_2.1-1 assertthat_0.2.1 ## [40] posterior_1.6.0 vctrs_0.6.5 R6_2.5.1 ## [43] matrixStats_1.5.0 stats4_4.4.2 lifecycle_1.0.4 ## [46] stringr_1.5.1 fs_1.6.5 htmlwidgets_1.6.4 ## [49] ragg_1.3.3 pkgconfig_2.0.3 desc_1.4.3 ## [52] pkgdown_2.1.1 RcppParallel_5.1.9 pillar_1.10.1 ## [55] bslib_0.8.0 gtable_0.3.6 loo_2.8.0 ## [58] glue_1.8.0 Rcpp_1.0.14 systemfonts_1.2.0 ## [61] xfun_0.50 tibble_3.2.1 tidyselect_1.2.1 ## [64] farver_2.1.2 bayesplot_1.11.1 htmltools_0.5.8.1 ## [67] labeling_0.4.3 rmarkdown_2.29 compiler_4.4.2 ## [70] distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"RBesT for a Normal Endpoint","text":"R Bayesian evidence synthesis Tools (RBesT) created facilitate use historical information clinical trials. relevant historical information identified, RBesT supports derivation informative priors via Meta-Analytic-Predictive (MAP) approach [1], evaluation trial’s operating characteristics, data analysis actual trial data. RBesT developed endpoints number well known distributions. consider example normally distributed response variable.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"historical-data","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Historical Data","title":"RBesT for a Normal Endpoint","text":"Let’s look Crohn’s disease example data [2] (data-set crohn RBesT). primary endpoint change baseline Crohn’s Disease Activity Index (CDAI), assumed normally distributed. Note CDAI, improved outcome corresponds negative change baseline. First historical studies get estimated standard deviation response variable σ\\sigma = 88, used obtain standard errors effect estimates.","code":"dat <- crohn crohn_sigma <- 88 dat$y.se <- crohn_sigma / sqrt(dat$n)"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"derivation-of-map-prior","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Derivation of MAP Prior","title":"RBesT for a Normal Endpoint","text":"MAP prior can derived function gMAP. -trial heterogeneity parameter τ\\tau governs much information shared historical trials design analysis future trials. normal case known sampling standard deviation σ\\sigma, amount borrowing historical data depends ratio τ/σ\\tau/\\sigma. conservative choice prior τ\\tau HalfNormal(0, σ/2\\sigma/2) distribution. prior intercept recommend “unit-information” prior [3] set precision corresponding single observation centered change baseline. Please refer help page ?gMAP detailed information. set.seed function used make results exactly reproducible.","code":"library(RBesT) set.seed(689654) map_mcmc <- gMAP(cbind(y, y.se) ~ 1 | study, weights = n, data = dat, family = gaussian, beta.prior = cbind(0, crohn_sigma), tau.dist = \"HalfNormal\", tau.prior = cbind(0, crohn_sigma / 2) ) print(map_mcmc) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(y, y.se) ~ 1 | study, family = gaussian, ## data = dat, weights = n, tau.dist = \"HalfNormal\", tau.prior = cbind(0, ## crohn_sigma/2), beta.prior = cbind(0, crohn_sigma)) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## Estimated reference scale : 88 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 14.30 9.38 1.54 12.20 36.80 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## -49.7 18.6 -88.4 -48.7 -12.3 ## a graphical representation is also available pl <- plot(map_mcmc) ## a number of plots are immediately defined names(pl) ## [1] \"densityThetaStar\" \"densityThetaStarLink\" \"forest_model\" ## forest plot with model estimates print(pl$forest_model)"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"approximation-of-map-prior-using-a-mixture-distribution","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Approximation of MAP Prior using a Mixture Distribution","title":"RBesT for a Normal Endpoint","text":"Next, MCMC MAP prior previous section converted parametric representation automixfit function. function fits parametric mixture representation using expectation-maximization (EM). number mixture components chosen automatically using AIC. One can also specify number components mixture via mixfit function compare automixfit outcome.","code":"map <- automixfit(map_mcmc) print(map) ## EM for Normal Mixture Model ## Log-Likelihood = -17021.66 ## ## Univariate normal mixture ## Reference scale: 88 ## Mixture Components: ## comp1 comp2 comp3 ## w 0.4366963 0.4324896 0.1308141 ## m -47.7396255 -51.3051003 -51.1267753 ## s 8.4310808 18.1462655 36.1496171 ## check accuracy of mixture fit plot(map)$mix"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"effective-sample-size-ess","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Effective Sample Size (ESS)","title":"RBesT for a Normal Endpoint","text":"main advantage using historical information possibility reduce number control patients, informative prior effectively equivalent certain number control patients. called effective sample size (ESS) can calculated RBesT ess function. study protocol Crohn’s disease data example, conservative moment-based ESS 20 used reduce planned sample size control group.","code":"round(ess(map)) ## default elir method ## Using default prior reference scale 88 ## [1] 37 round(ess(map, method = \"morita\")) ## Using default prior reference scale 88 ## [1] 78 round(ess(map, method = \"moment\")) ## Using default prior reference scale 88 ## [1] 22"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"robustification-of-map-prior","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Robustification of MAP Prior","title":"RBesT for a Normal Endpoint","text":"recommend robustifying [5] prior robustify function, protects type-error inflation presence prior-data conflict. normal case strongly recommend explicitly choosing mean robust component. use −50-50 consistent mean MAP prior. Furthermore, 20% probability used additional robust (unit-information) mixture component. choice probability reflects confidence validitiy model assumptions, .e. possibility non-exchangable control group enrolled per inclusion/exclusion criteria current trial compared historical control group population. Note robustification decreases ESS.","code":"## add a 20% non-informative mixture component map_robust <- robustify(map, weight = 0.2, mean = -50) ## Using default prior reference scale 88 print(map_robust) ## Univariate normal mixture ## Reference scale: 88 ## Mixture Components: ## comp1 comp2 comp3 robust ## w 0.3493570 0.3459917 0.1046513 0.2000000 ## m -47.7396255 -51.3051003 -51.1267753 -50.0000000 ## s 8.4310808 18.1462655 36.1496171 88.0000000 round(ess(map_robust)) ## Using default prior reference scale 88 ## [1] 27"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"operating-characteristics-of-design-options","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Operating Characteristics of Design Options","title":"RBesT for a Normal Endpoint","text":"Typically, operating characteristics required evaluate proposed design compare design options. RBesT requires input decision rules via decision2S function calculates operating characteristics oc2S function. calculation expedited based analytic expressions. following compare design options, differ choice control priors sample size control group planned trial. may design factors (outcome standard deviation), considered comparing design options. factors considered simplicity purpose.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"decision-rules","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Decision Rules","title":"RBesT for a Normal Endpoint","text":"Consider 2-arm design placebo (informative prior) experimental treatment. dual-criterion success defined follows: Criterion 1:Pr(θact−θpbo<0)>0.95Criterion 2:Pr(θact−θpbo<−50)>0.50. \\begin{align*} \\textrm{Criterion 1:} & \\Pr(\\theta_{act} - \\theta_{pbo} \\lt 0) &> 0.95 \\\\ \\textrm{Criterion 2:} & \\Pr(\\theta_{act} - \\theta_{pbo} \\lt -50) &> 0.50. \\end{align*} Equivalently, second criterion requires posterior median difference exceeds -50. dual-criteria account statistical significance well clinical relevance. Note negative change baseline CDAI corresponds improvement.","code":"## dual decision criteria ## pay attention to \"lower.tail\" argument and the order of active and pbo poc <- decision2S(pc = c(0.95, 0.5), qc = c(0, -50), lower.tail = TRUE) print(poc) ## 2 sample decision function ## Conditions for acceptance: ## P(theta1 - theta2 <= 0) > 0.95 ## P(theta1 - theta2 <= -50) > 0.5 ## Link: identity"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"design-options","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Design Options","title":"RBesT for a Normal Endpoint","text":"active group use weakly informative (unit-information) prior used robustification step MAP prior. Also, set design options different choices control prior different sizes control group.","code":"## set up prior for active group weak_prior <- mixnorm(c(1, -50, 1), sigma = crohn_sigma, param = \"mn\") n_act <- 40 n_pbo <- 20 ## four designs ## \"b\" means a balanced design, 1:1 ## \"ub\" means 40 in active and 20 in placebo design_noprior_b <- oc2S(weak_prior, weak_prior, n_act, n_act, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma ) design_noprior_ub <- oc2S(weak_prior, weak_prior, n_act, n_pbo, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma ) design_nonrob_ub <- oc2S(weak_prior, map, n_act, n_pbo, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma ) design_rob_ub <- oc2S(weak_prior, map_robust, n_act, n_pbo, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma )"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"type-i-error","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Type I Error","title":"RBesT for a Normal Endpoint","text":"type can increased compared nominal α\\alpha level case conflict trial data prior. robustified MAP prior can reduce type error inflation case lower level.","code":"# the range for true values cfb_truth <- seq(-120, -40, by = 1) typeI1 <- design_noprior_b(cfb_truth, cfb_truth) typeI2 <- design_noprior_ub(cfb_truth, cfb_truth) typeI3 <- design_nonrob_ub(cfb_truth, cfb_truth) typeI4 <- design_rob_ub(cfb_truth, cfb_truth) ocI <- rbind( data.frame( cfb_truth = cfb_truth, typeI = typeI1, design = \"40:40 with non-informative priors\" ), data.frame( cfb_truth = cfb_truth, typeI = typeI2, design = \"40:20 with non-informative priors\" ), data.frame( cfb_truth = cfb_truth, typeI = typeI3, design = \"40:20 with non-robust prior for placebo\" ), data.frame( cfb_truth = cfb_truth, typeI = typeI4, design = \"40:20 with robust prior for placebo\" ) ) ggplot(ocI, aes(cfb_truth, typeI, colour = design)) + geom_line() + ggtitle(\"Type I Error\") + xlab(expression(paste(\"True value of change from baseline \", mu[act] == mu[pbo]))) + ylab(\"Type I error\") + coord_cartesian(ylim = c(0, 0.2)) + theme(legend.justification = c(1, 1), legend.position = c(0.95, 0.85)) ## Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2 ## 3.5.0. ## ℹ Please use the `legend.position.inside` argument of `theme()` instead. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated."},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"power","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Power","title":"RBesT for a Normal Endpoint","text":"power shows gain using informative prior control arm; .e. 90% power reached smaller δ\\delta values compared design weakly informative priors arms balanced design.","code":"delta <- seq(-80, 0, by = 1) m <- summary(map)[\"mean\"] cfb_truth1 <- m + delta # active for 1 cfb_truth2 <- m + 0 * delta # pbo for 2 power1 <- design_noprior_b(cfb_truth1, cfb_truth2) power2 <- design_noprior_ub(cfb_truth1, cfb_truth2) power3 <- design_nonrob_ub(cfb_truth1, cfb_truth2) power4 <- design_rob_ub(cfb_truth1, cfb_truth2) ocP <- rbind( data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power1, design = \"40:40 with non-informative priors\" ), data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power2, design = \"40:20 with non-informative priors\" ), data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power3, design = \"40:20 with non-robust prior for placebo\" ), data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power4, design = \"40:20 with robust prior for placebo\" ) ) ggplot(ocP, aes(delta, power, colour = design)) + geom_line() + ggtitle(\"Power\") + xlab(\"True value of difference (act - pbo)\") + ylab(\"Power\") + scale_y_continuous(breaks = c(seq(0, 1, 0.2), 0.9)) + scale_x_continuous(breaks = c(seq(-80, 0, 20), -70)) + geom_hline(yintercept = 0.9, linetype = 2) + geom_vline(xintercept = -70, linetype = 2) + theme(legend.justification = c(1, 1), legend.position = c(0.95, 0.85))"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"final-analysis-with-trial-data","dir":"Articles","previous_headings":"","what":"Final Analysis with Trial Data","title":"RBesT for a Normal Endpoint","text":"actual trial data available, final analysis can run RBesT via postmix function. real data used example, trial data led negative conclusion. However, note postmix assumes sampling standard deviation known fixed. Therefore, uncertainty estimate taken account.","code":"## one can either use summary data or individual data. See ?postmix. y.act <- -29.2 y.act.se <- 14.0 n.act <- 39 y.pbo <- -63.1 y.pbo.se <- 13.9 n.pbo <- 20 ## first obtain posterior distributions post_act <- postmix(weak_prior, m = y.act, se = y.act.se) post_pbo <- postmix(map_robust, m = y.pbo, se = y.pbo.se) ## then calculate probability for the dual criteria ## and compare to the predefined threshold values p1 <- pmixdiff(post_act, post_pbo, 0) print(p1) ## [1] 0.06149329 p2 <- pmixdiff(post_act, post_pbo, -50) print(p2) ## [1] 3.795469e-06 print(p1 > 0.95 & p2 > 0.5) ## [1] FALSE ## or we can use the decision function poc(post_act, post_pbo) ## [1] 0"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"references","dir":"Articles","previous_headings":"Final Analysis with Trial Data","what":"References","title":"RBesT for a Normal Endpoint","text":"[1] Neuenschwander B et. al, Clin Trials. 2010; 7(1):5-18 [2] Hueber W. et. al, Gut, 2012, 61(12):1693-1700 [3] Kass RE, Wasserman L, J Amer Statist Assoc; 1995, 90(431):928-934. [4] Morita S. et. al, Biometrics 2008;64(2):595-602 [5] Schmidli H. et. al, Biometrics 2014;70(4):1023-1032","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"r-session-info","dir":"Articles","previous_headings":"Final Analysis with Trial Data","what":"R Session Info","title":"RBesT for a Normal Endpoint","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] ggplot2_3.5.1 knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 crayon_1.5.3 ## [25] rlang_1.1.5 munsell_0.5.1 withr_3.0.2 ## [28] cachem_1.1.0 yaml_2.3.10 StanHeaders_2.32.10 ## [31] parallel_4.4.2 tools_4.4.2 rstan_2.32.6 ## [34] inline_0.3.21 reshape2_1.4.4 rstantools_2.4.0 ## [37] checkmate_2.3.2 dplyr_1.1.4 colorspace_2.1-1 ## [40] assertthat_0.2.1 posterior_1.6.0 vctrs_0.6.5 ## [43] R6_2.5.1 matrixStats_1.5.0 stats4_4.4.2 ## [46] lifecycle_1.0.4 stringr_1.5.1 fs_1.6.5 ## [49] htmlwidgets_1.6.4 ragg_1.3.3 pkgconfig_2.0.3 ## [52] desc_1.4.3 pkgdown_2.1.1 RcppParallel_5.1.9 ## [55] pillar_1.10.1 bslib_0.8.0 gtable_0.3.6 ## [58] loo_2.8.0 glue_1.8.0 Rcpp_1.0.14 ## [61] systemfonts_1.2.0 xfun_0.50 tibble_3.2.1 ## [64] tidyselect_1.2.1 farver_2.1.2 bayesplot_1.11.1 ## [67] htmltools_0.5.8.1 labeling_0.4.3 rmarkdown_2.29 ## [70] compiler_4.4.2 distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"map-prior-for-the-sampling-standard-deviation","dir":"Articles","previous_headings":"","what":"MAP prior for the sampling standard deviation","title":"Meta-Analytic-Predictive Priors for Variances","text":"MAP analysis performed log\\log variance, actually interested MAP respective sampling standard deviation. Since sampling standard deviation strictly positive quantity suitable approximate MCMC posterior MAP prior using mixture Γ\\Gamma variates, can done using RBesT :","code":"map_mc_post <- as.matrix(map_mc) sd_trans <- compose(sqrt, exp) mcmc_intervals(map_mc_post, regex_pars = \"theta\", transformation = sd_trans) map_sigma_mc <- sd_trans(map_mc_post[, c(\"theta_pred\")]) map_sigma <- automixfit(map_sigma_mc, type = \"gamma\") plot(map_sigma)$mix ## 95% interval MAP for the sampling standard deviation summary(map_sigma) ## mean sd 2.5% 50.0% 97.5% ## 10.980236 1.401089 8.283373 10.921528 14.063679"},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"normal-approximation-of-a-loggamma-variate","dir":"Articles","previous_headings":"","what":"Normal approximation of a logΓ\\log\\Gamma variate","title":"Meta-Analytic-Predictive Priors for Variances","text":"Γ(y|α,β)\\Gamma(y|\\alpha, \\beta) variate yy, log\\log transformed, z=log(y)z = \\log(y), law transformations univariate densities: y|α,β∼Γ(α,β) y|\\alpha,\\beta \\sim \\Gamma(\\alpha,\\beta) p(z)=p(y)y=p(exp(z))exp(z) p(z) = p(y) \\, y = p(\\exp(z)) \\, \\exp(z) z|α,β∼logΓ(α,β) z|\\alpha,\\beta \\sim \\log\\Gamma(\\alpha,\\beta)⇔exp(z)|α,β∼Γ(α,β)exp(z)\\Leftrightarrow \\exp(z)|\\alpha,\\beta \\sim \\Gamma(\\alpha,\\beta) \\, \\exp(z) first second moment zz E[z]=ψ(α)−log(β) E[z] = \\psi(\\alpha) - \\log(\\beta)Var[z]=ψ(1)(α). Var[z] = \\psi^{(1)}(\\alpha). short simulation demonstrates results: see ν=9\\nu=9 , approximation normal density reasonable. However, comparing function ν\\nu 2.52.5%, 5050% 97.597.5% quantiles correct distribution respective approximate distribution can assess adequatness approximation. respective R code accessible via vignette overview page graphical result presented two different σ\\sigma values:","code":"gamma_dist <- mixgamma(c(1, 18, 6)) ## logGamma density dlogGamma <- function(z, a, b, log = FALSE) { n <- exp(z) if (!log) { return(dgamma(n, a, b) * n) } else { return(dgamma(n, a, b, log = TRUE) + z) } } a <- gamma_dist[2, 1] b <- gamma_dist[3, 1] m <- digamma(a) - log(b) v <- psigamma(a, 1) ## compare simulated histogram of log transformed Gamma variates to ## analytic density and approximate normal sim <- rmix(gamma_dist, 1E5) mcmc_hist(data.frame(logGamma = log(sim)), freq = FALSE, binwidth = 0.1) + overlay_function(fun = dlogGamma, args = list(a = a, b = b), aes(linetype = \"LogGamma\")) + overlay_function(fun = dnorm, args = list(mean = m, sd = sqrt(v)), aes(linetype = \"NormalApprox\")) ## Warning in stat_function(..., inherit.aes = FALSE): All aesthetics have length 1, but the data has 100000 rows. ## ℹ Please consider using `annotate()` or provide this layer with data containing ## a single row. ## All aesthetics have length 1, but the data has 100000 rows. ## ℹ Please consider using `annotate()` or provide this layer with data containing ## a single row."},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"acknowledgements","dir":"Articles","previous_headings":"Normal approximation of a logΓ\\log\\Gamma variate","what":"Acknowledgements","title":"Meta-Analytic-Predictive Priors for Variances","text":"Many thanks Ping Chen Simon Wandel pointing issue transformation used earlier vignette.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"references","dir":"Articles","previous_headings":"Normal approximation of a logΓ\\log\\Gamma variate","what":"References","title":"Meta-Analytic-Predictive Priors for Variances","text":"[1] Schmidli, H., et. al, Comp. Stat. Data Analysis, 2017, 113:100-110 [2] https://en.wikipedia.org/wiki/Gamma_distribution#Logarithmic_expectation_and_variance [3] Gelman , et. al, Bayesian Data Analysis. Third edit., 2014., Chapter 4, p. 84","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"r-session-info","dir":"Articles","previous_headings":"Normal approximation of a logΓ\\log\\Gamma variate","what":"R Session Info","title":"Meta-Analytic-Predictive Priors for Variances","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] bayesplot_1.11.1 purrr_1.0.2 dplyr_1.1.4 ggplot2_3.5.1 ## [5] knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 rlang_1.1.5 ## [25] munsell_0.5.1 withr_3.0.2 cachem_1.1.0 ## [28] yaml_2.3.10 StanHeaders_2.32.10 parallel_4.4.2 ## [31] tools_4.4.2 rstan_2.32.6 inline_0.3.21 ## [34] reshape2_1.4.4 rstantools_2.4.0 checkmate_2.3.2 ## [37] colorspace_2.1-1 assertthat_0.2.1 posterior_1.6.0 ## [40] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [43] stats4_4.4.2 lifecycle_1.0.4 stringr_1.5.1 ## [46] fs_1.6.5 htmlwidgets_1.6.4 ragg_1.3.3 ## [49] pkgconfig_2.0.3 desc_1.4.3 pkgdown_2.1.1 ## [52] RcppParallel_5.1.9 pillar_1.10.1 bslib_0.8.0 ## [55] gtable_0.3.6 loo_2.8.0 glue_1.8.0 ## [58] Rcpp_1.0.14 systemfonts_1.2.0 xfun_0.50 ## [61] tibble_3.2.1 tidyselect_1.2.1 farver_2.1.2 ## [64] htmltools_0.5.8.1 labeling_0.4.3 rmarkdown_2.29 ## [67] compiler_4.4.2 distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Novartis Pharma AG. Copyright holder. Sebastian Weber. Author, maintainer. Beat Neuenschwander. Contributor. Heinz Schmidli. Contributor. Baldur Magnusson. Contributor. Yue Li. Contributor. Satrajit Roychoudhury. Contributor. Lukas . Widmer. Contributor. Trustees Columbia University. Copyright holder. R/stanmodels.R, configure, configure.win","code":""},{"path":"https://opensource.nibr.com/RBesT/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Weber S, Li Y, Seaman JW, Kakizume T, Schmidli H (2021). “Applying Meta-Analytic-Predictive Priors R Bayesian Evidence Synthesis Tools.” Journal Statistical Software, 100(19), 1–32. doi:10.18637/jss.v100.i19.","code":"@Article{, title = {Applying Meta-Analytic-Predictive Priors with the {R} {B}ayesian Evidence Synthesis Tools}, author = {Sebastian Weber and Yue Li and John W. Seaman and Tomoyuki Kakizume and Heinz Schmidli}, journal = {Journal of Statistical Software}, year = {2021}, volume = {100}, number = {19}, pages = {1--32}, doi = {10.18637/jss.v100.i19}, }"},{"path":"https://opensource.nibr.com/RBesT/index.html","id":"rbest-r-bayesian-evidence-synthesis-tools","dir":"","previous_headings":"","what":"R Bayesian Evidence Synthesis Tools","title":"R Bayesian Evidence Synthesis Tools","text":"Tool-set support Bayesian evidence synthesis. includes meta-analysis, (robust) prior derivation historical data, operating characteristics analysis (1 2 sample cases). Please refer Weber et al. (2021) details applying package Neuenschwander et al. (2010) Schmidli et al. (2014) explain details methodology.","code":""},{"path":"https://opensource.nibr.com/RBesT/index.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting Started","title":"R Bayesian Evidence Synthesis Tools","text":"get quick overview package functionality, please refer introductory vignettes. recommend starting Getting started RBesT (binary) vignette first read.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":null,"dir":"Reference","previous_headings":"","what":"Ankylosing Spondylitis. — AS","title":"Ankylosing Spondylitis. — AS","text":"Data set containing historical information placebo phase II trial ankylosing spondylitis patients. primary efficacy endpoint percentage patients 20 according Assessment SpondyloArthritis international Society criteria improvement (ASAS20) week 6.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ankylosing Spondylitis. — AS","text":"","code":"AS"},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ankylosing Spondylitis. — AS","text":"data frame 8 rows 3 variables: study study n study size r number events","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Ankylosing Spondylitis. — AS","text":"Baeten D. et. al, Lancet, 2013, (382), 9906, p 1705","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ankylosing Spondylitis. — AS","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) set.seed(34563) map_AS <- gMAP(cbind(r, n - r) ~ 1 | study, family = binomial, data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2 ) #> Assuming default prior location for beta: 0 #> Warning: The largest R-hat is 1.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Warning: Maximal Rhat > 1.1. Consider increasing RBesT.MC.warmup MCMC parameter. #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":null,"dir":"Reference","previous_headings":"","what":"Exact Confidence interval for Binary Proportion — BinaryExactCI","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"function calculates exact confidendence interval response rate presented \\(n\\) \\(r\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"","code":"BinaryExactCI(r, n, alpha = 0.05, drop = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"r Number success responder n Sample size alpha confidence level drop Determines drop called result","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"100 (1-\\(\\alpha\\))% exact confidence interval given response rate","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"Confidence intervals obtained procedure first given Clopper Pearson (1934). guarantees confidence level least (1-\\(\\alpha\\)). Details can found publication listed .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"Clopper, C. J. & Pearson, E. S. use confidence fiducial limits illustrated case binomial. Biometrika 1934.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"","code":"BinaryExactCI(3, 20, 0.05) #> 2.5% 97.5% #> 0.03207094 0.37892683"},{"path":"https://opensource.nibr.com/RBesT/reference/Curry.html","id":null,"dir":"Reference","previous_headings":"","what":"Functional programming utilities — Curry","title":"Functional programming utilities — Curry","text":"function functional","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/Curry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Functional programming utilities — Curry","text":"","code":"Curry(FUN, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":null,"dir":"Reference","previous_headings":"","what":"R Bayesian Evidence Synthesis Tools — RBesT-package","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"RBesT tools designed support derivation parametric informative priors, asses design characeristics perform analyses. Supported endpoints include normal, binary Poisson.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"introductory material, please refer vignettes include Introduction (binary) Introduction (normal) Customizing RBesT Plots Robust MAP, advanced usage main function package gMAP. See help page detailed description statistical model.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"version-history","dir":"Reference","previous_headings":"","what":"Version History","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"See NEWS.md file.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"Stan Development Team (2020). RStan: R interface Stan. R package version 2.19.3. https://mc-stan.org","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"Maintainer: Sebastian Weber sebastian.weber@novartis.com contributors: Novartis Pharma AG [copyright holder] Beat Neuenschwander beat.neuenschwander@novartis.com [contributor] Heinz Schmidli heinz.schmidli@novartis.com [contributor] Baldur Magnusson baldur.magnusson@novartis.com [contributor] Yue Li yue-1.li@novartis.com [contributor] Satrajit Roychoudhury satrajit.roychoudhury@novartis.com [contributor] Lukas . Widmer lukas_andreas.widmer@novartis.com (ORCID) [contributor] Trustees Columbia University (R/stanmodels.R, configure, configure.win) [copyright holder]","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize Arrays — SimSum","title":"Summarize Arrays — SimSum","text":"function calculates summary statistics arbitrary arrays.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize Arrays — SimSum","text":"","code":"SimSum( x, min.max = FALSE, n.sim = FALSE, probs = c(0.025, 0.5, 0.975), margin = ifelse(is.null(dim(x) | length(dim(x)) == 1), 2, length(dim(x))) )"},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize Arrays — SimSum","text":"x Object summarize can numerical vector, matrix multi-dimensional array min.max Enables include minimum maximum output. n.sim Enables include number observations output. probs Quantiles output. margin Margin input array summary function applied.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize Arrays — SimSum","text":"function calculates default mean, standard deviation specified qantiles default median 95 mulit-dimensional array specified x, function default calculate summaries margin largest dimension. case vector matrix, function transpose results better readabiliy.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":null,"dir":"Reference","previous_headings":"","what":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"Fitting series mixtures conjugate distributions sample, using Expectation-Maximization (EM). number mixture components specified vector Nc. First Nc[1] component mixture fitted, Nc[2] component mixture, . mixture providing best AIC value selected.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"","code":"automixfit(sample, Nc = seq(1, 4), k = 6, thresh = -Inf, verbose = FALSE, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"sample Sample fitted mixture distribution. Nc Vector mixture components try (default seq(1,4)). k Penalty parameter AIC calculation (default 6) thresh procedure stops difference subsequent AIC values smaller threshold (default -Inf). Setting threshold 0 stops automixfit AIC becomes worse. verbose Enable verbose logging. ... arguments passed mixfit, including type.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"result best fitting mixture model returned, .e. model lowest AIC. models saved attribute models.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"type argument specifies distribution mixture components, can normal, beta gamma distribution. penalty parameter k 2 standard AIC definition. Collet (2003) suggested use values range 2 6, larger values k penalize complex models. favor mixtures fewer components value 6 used default.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"Collet D. Modeling Survival Data Medical Research. 2003; Chapman Hall/CRC.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"","code":"# random sample of size 1000 from a mixture of 2 beta components bm <- mixbeta(beta1 = c(0.4, 20, 90), beta2 = c(0.6, 35, 65)) bmSamp <- rmix(bm, 1000) # fit with EM mixture models with up to 10 components and stop if # AIC increases bmFit <- automixfit(bmSamp, Nc = 1:10, thresh = 0, type = \"beta\") bmFit #> EM for Beta Mixture Model #> Log-Likelihood = 1099.367 #> #> Univariate beta mixture #> Mixture Components: #> comp1 comp2 #> w 0.586131 0.413869 #> a 33.422658 18.251968 #> b 61.784396 82.825370 # advanced usage: find out about all discarded models bmFitAll <- attr(bmFit, \"models\") sapply(bmFitAll, AIC, k = 6) #> 2 3 1 #> -2168.735 -2150.802 -1871.069"},{"path":"https://opensource.nibr.com/RBesT/reference/chains2sample.html","id":null,"dir":"Reference","previous_headings":"","what":"Scrambles the order of a mcmc array object for usage as a mcmc sample. It is advisable to set order once per mcmc run, otherwise correlations in the mcmc sample will be lost. — chains2sample","title":"Scrambles the order of a mcmc array object for usage as a mcmc sample. It is advisable to set order once per mcmc run, otherwise correlations in the mcmc sample will be lost. — chains2sample","text":"Scrambles order mcmc array object usage mcmc sample. advisable set order per mcmc run, otherwise correlations mcmc sample lost.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/chains2sample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Scrambles the order of a mcmc array object for usage as a mcmc sample. It is advisable to set order once per mcmc run, otherwise correlations in the mcmc sample will be lost. — chains2sample","text":"","code":"chains2sample(chains, order, drop = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/colVars.html","id":null,"dir":"Reference","previous_headings":"","what":"Fast column-wise calculation of unbiased variances — colVars","title":"Fast column-wise calculation of unbiased variances — colVars","text":"Fast column-wise calculation unbiased variances","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/colVars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fast column-wise calculation of unbiased variances — colVars","text":"","code":"colVars(a)"},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":null,"dir":"Reference","previous_headings":"","what":"Ulcerative Colitis. — colitis","title":"Ulcerative Colitis. — colitis","text":"Data set containing historical information placebo arm phase II proof--concept trial treatment ulcerative colitis. primary outcome remission week 8 (binary).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ulcerative Colitis. — colitis","text":"","code":"colitis"},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ulcerative Colitis. — colitis","text":"data frame 4 rows 3 variables: study study n study size r number events","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Ulcerative Colitis. — colitis","text":"Neuenschwander B, Capkun-Niggli G, Branson M, Spiegelhalter DJ. Summarizing historical information controls clinical trials. Clin Trials. 2010; 7(1):5-18","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":null,"dir":"Reference","previous_headings":"","what":"Crohn's disease. — crohn","title":"Crohn's disease. — crohn","text":"Data set containing historical information placebo arm relevant studies treatment Crohn's disease. primary outcome change baseline Crohn's Disease Activity Index (CDAI) duration 6 weeks. Standard deviation change baseline endpoint approximately 88.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Crohn's disease. — crohn","text":"","code":"crohn"},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Crohn's disease. — crohn","text":"data frame 4 rows 3 variables: study study n study size y mean CDAI change","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Crohn's disease. — crohn","text":"Hueber W. et. al, Gut, 2012, 61(12):1693-1700","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Crohn's disease. — crohn","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) set.seed(546346) map_crohn <- gMAP(cbind(y, y.se) ~ 1 | study, family = gaussian, data = transform(crohn, y.se = 88 / sqrt(n)), weights = n, tau.dist = \"HalfNormal\", tau.prior = 44, beta.prior = cbind(0, 88) ) #> Warning: The largest R-hat is 1.09, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":null,"dir":"Reference","previous_headings":"","what":"Beta-Binomial Probabilities — dBetaBinomial","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"Beta-Binomial Probabilities","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"","code":"dBetaBinomial(r, n, a, b, log = FALSE)"},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"r, n number successes (responders) n , b parameters Beta distribution response probability","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"r,n,,b can scalar vectors. vectors used, must length","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Function for 1 Sample Designs — decision1S","title":"Decision Function for 1 Sample Designs — decision1S","text":"function sets 1 sample one-sided decision function arbitrary number conditions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Function for 1 Sample Designs — decision1S","text":"","code":"decision1S(pc = 0.975, qc = 0, lower.tail = TRUE) oc1Sdecision(pc = 0.975, qc = 0, lower.tail = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Function for 1 Sample Designs — decision1S","text":"pc Vector critical cumulative probabilities. qc Vector respective critical values. Must match length pc. lower.tail Logical; TRUE (default), probabilities \\(P(X \\leq x)\\), otherwise, \\(P(X > x)\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Function for 1 Sample Designs — decision1S","text":"function returns decision function takes two arguments. first argument expected mixture (posterior) distribution tested specified conditions met. logical second argument determines function acts indicator function function returns distance decision boundary condition log-space, .e. distance 0 decision boundary, negative 0 decision positive 1 decision.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Function for 1 Sample Designs — decision1S","text":"function creates one-sided decision function takes two arguments. first argument expected mixture (posterior) distribution. distribution tested whether fulfills required threshold conditions specified pc qc arguments returns 1 conditions met 0 otherwise. Hence, lower.tail=TRUE condition \\(\\) equivalent $$P(\\theta \\leq q_{c,}) > p_{c,}$$ decision function implemented indicator function basis heavy-side step function \\(H(x)\\) \\(0\\) \\(x \\leq 0\\) \\(1\\) \\(x > 0\\). conditions must met, final indicator function returns $$\\Pi_i H_i(P(\\theta \\leq q_{c,}) - p_{c,} ).$$ second argument set TRUE distance metric returned component-wise per defined condition $$ D_i = \\log(P(\\theta < q_{c,})) - \\log(p_{c,}) .$$ indicator functions can used input 1-sample boundary, OC PoS calculations using oc1S pos1S .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Decision Function for 1 Sample Designs — decision1S","text":"oc1Sdecision(): Deprecated old function name. Please use decision1S instead.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Decision Function for 1 Sample Designs — decision1S","text":"Neuenschwander B, Rouyrre N, Hollaender H, Zuber E, Branson M. proof concept phase II non-inferiority criterion. Stat. Med.. 2011, 30:1618-1627","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Function for 1 Sample Designs — decision1S","text":"","code":"# see Neuenschwander et al., 2011 # example is for a time-to-event trial evaluating non-inferiority # using a normal approximation for the log-hazard ratio # reference scale s <- 2 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) # n for which design was intended nL <- 233 c1 <- theta_ni - za * s / sqrt(n1) # flat prior flat_prior <- mixnorm(c(1, 0, 100), sigma = s) # standard NI design decA <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # for double criterion with indecision point (mean estimate must be # lower than this) theta_c <- c1 # double criterion design # statistical significance (like NI design) dec1 <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # require mean to be at least as good as theta_c dec2 <- decision1S(0.5, theta_c, lower.tail = TRUE) # combination decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) theta_eval <- c(theta_a, theta_c, theta_ni) # we can display the decision function definition decComb #> 1 sample decision function #> Conditions for acceptance: #> P(theta <= 0.4) > 0.95 #> P(theta <= 0.13576435472344) > 0.5 # and use it to decide if a given distribution fulfills all # criterions defined # for the prior decComb(flat_prior) #> [1] 0 # or for a possible outcome of the trial # here with HR of 0.8 for 40 events decComb(postmix(flat_prior, m = log(0.8), n = 40)) #> Using default prior reference scale 2 #> [1] 1"},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Boundary for 1 Sample Designs — decision1S_boundary","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"Calculates decision boundary 1 sample design. critical value decision function change 0 (failure) 1 (success).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"","code":"decision1S_boundary(prior, n, decision, ...) # S3 method for class 'betaMix' decision1S_boundary(prior, n, decision, ...) # S3 method for class 'normMix' decision1S_boundary(prior, n, decision, sigma, eps = 1e-06, ...) # S3 method for class 'gammaMix' decision1S_boundary(prior, n, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"prior Prior analysis. n Sample size experiment. decision One-sample decision function use; see decision1S. ... Optional arguments. sigma fixed reference scale. left unspecified, default reference scale prior assumed. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"Returns critical value \\(y_c\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"specification 1 sample design (prior, sample size decision function, \\(D(y)\\)), uniquely defines decision boundary $$y_c = \\max_y\\{D(y) = 1\\},$$ maximal value \\(y\\) whenever decision \\(D(y)\\) function changes value 1 0 decision function lower.tail=TRUE (otherwise definition \\(y_c = \\max_{y}\\{D(y) = 0\\}\\)). decision function may change single critical value one-sided decision functions supported. , \\(y\\) defined binary Poisson endpoints sufficient statistic \\(y = \\sum_{=1}^{n} y_i\\) normal case mean \\(\\bar{y} = 1/n \\sum_{=1}^n y_i\\). convention critical value \\(y_c\\) depends whether left (lower.tail=TRUE) right-sided decision function (lower.tail=FALSE) used. lower.tail=TRUE critical value \\(y_c\\) largest value decision 1, \\(D(y \\leq y_c) = 1\\), lower.tail=FALSE \\(D(y > y_c) = 1\\) holds. aligned cumulative density function definition within R (see example pbinom).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"decision1S_boundary(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. decision1S_boundary(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture prior mean. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function decision1S_boundary extra argument eps (defaults \\(10^{-6}\\)). critical value \\(y_c\\) searched region probability mass 1-eps \\(y\\). decision1S_boundary(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function decision1S_boundary takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"","code":"# non-inferiority example using normal approximation of log-hazard # ratio, see ?decision1S for all details s <- 2 flat_prior <- mixnorm(c(1, 0, 100), sigma = s) nL <- 233 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) theta_c <- theta_ni - za * s / sqrt(n1) # double criterion design # statistical significance (like NI design) dec1 <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # require mean to be at least as good as theta_c dec2 <- decision1S(0.5, theta_c, lower.tail = TRUE) # combination decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) # critical value of double criterion design decision1S_boundary(flat_prior, nL, decComb) #> Using default prior reference scale 2 #> [1] 0.1357511 # ... is limited by the statistical significance ... decision1S_boundary(flat_prior, nL, dec1) #> Using default prior reference scale 2 #> [1] 0.1844494 # ... or the indecision point (whatever is smaller) decision1S_boundary(flat_prior, nL, dec2) #> Using default prior reference scale 2 #> [1] 0.1357511"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Function for 2 Sample Designs — decision2S","title":"Decision Function for 2 Sample Designs — decision2S","text":"function sets 2 sample one-sided decision function arbitrary number conditions difference distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Function for 2 Sample Designs — decision2S","text":"","code":"decision2S( pc = 0.975, qc = 0, lower.tail = TRUE, link = c(\"identity\", \"logit\", \"log\") ) oc2Sdecision( pc = 0.975, qc = 0, lower.tail = TRUE, link = c(\"identity\", \"logit\", \"log\") )"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Function for 2 Sample Designs — decision2S","text":"pc Vector critical cumulative probabilities difference distribution. qc Vector respective critical values difference distribution. Must match length pc. lower.tail Logical; TRUE (default), probabilities \\(P(X \\leq x)\\), otherwise, \\(P(X > x)\\). link Enables application link function prior evaluating difference distribution. Can take one values identity (default), logit log.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Function for 2 Sample Designs — decision2S","text":"function returns decision function takes three arguments. first second argument expected mixture (posterior) distributions difference distribution formed conditions tested. third argument determines function acts indicator function function returns distance decision boundary condition log-space. , distance 0 decision boundary, negative 0 decision positive 1 decision.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Function for 2 Sample Designs — decision2S","text":"function creates one-sided decision function basis difference distribution 2 sample situation. support double criterion designs, see Neuenschwander et al., 2010, arbitrary number criterions can given. decision function demands probability mass critical value qc difference \\(\\theta_1 - \\theta_2\\) least pc. Hence, lower.tail=TRUE condition \\(\\) equivalent $$P(\\theta_1 - \\theta_2 \\leq q_{c,}) > p_{c,}$$ decision function implemented indicator function using heavy-side step function \\(H(x)\\) \\(0\\) \\(x \\leq 0\\) \\(1\\) \\(x > 0\\). conditions must met, final indicator function returns $$\\Pi_i H_i(P(\\theta_1 - \\theta_2 \\leq q_{c,}) - p_{c,} ),$$ \\(1\\) conditions met \\(0\\) otherwise. lower.tail=FALSE differences must greater given quantiles qc. Note whenever link identity requested, underlying densities first transformed using link function probabilties differences calculated transformed space. Hence, binary endpoint default identity link calculate risk differences, logit link lead decisions based differences logits corresponding criterion based log-odds. log link evaluate ratios instead absolute differences useful binary endpoint counting rates. respective critical quantiles qc must given transformed scale.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Decision Function for 2 Sample Designs — decision2S","text":"oc2Sdecision(): Deprecated old function name. Please use decision2S instead.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Decision Function for 2 Sample Designs — decision2S","text":"Gsponer T, Gerber F, Bornkamp B, Ohlssen D, Vandemeulebroecke M, Schmidli H.practical guide Bayesian group sequential designs. Pharm. Stat.. 2014; 13: 71-80","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Function for 2 Sample Designs — decision2S","text":"","code":"# see Gsponer et al., 2010 priorT <- mixnorm(c(1, 0, 0.001), sigma = 88, param = \"mn\") priorP <- mixnorm(c(1, -49, 20), sigma = 88, param = \"mn\") # the success criteria is for delta which are larger than some # threshold value which is why we set lower.tail=FALSE successCrit <- decision2S(c(0.95, 0.5), c(0, 50), FALSE) # the futility criterion acts in the opposite direction futilityCrit <- decision2S(c(0.90), c(40), TRUE) print(successCrit) #> 2 sample decision function #> Conditions for acceptance: #> P(theta1 - theta2 > 0) > 0.95 #> P(theta1 - theta2 > 50) > 0.5 #> Link: identity print(futilityCrit) #> 2 sample decision function #> Conditions for acceptance: #> P(theta1 - theta2 <= 40) > 0.9 #> Link: identity # consider decision for specific outcomes postP_interim <- postmix(priorP, n = 10, m = -50) #> Using default prior reference scale 88 postT_interim <- postmix(priorT, n = 20, m = -80) #> Using default prior reference scale 88 futilityCrit(postP_interim, postT_interim) #> [1] 0 successCrit(postP_interim, postT_interim) #> [1] 0 # Binary endpoint with double criterion decision on log-odds scale # 95% certain positive difference and an odds ratio of 2 at least decL2 <- decision2S(c(0.95, 0.5), c(0, log(2)), lower.tail = FALSE, link = \"logit\") # 95% certain positive difference and an odds ratio of 3 at least decL3 <- decision2S(c(0.95, 0.5), c(0, log(3)), lower.tail = FALSE, link = \"logit\") # data scenario post1 <- postmix(mixbeta(c(1, 1, 1)), n = 40, r = 10) post2 <- postmix(mixbeta(c(1, 1, 1)), n = 40, r = 18) # positive outcome and a median odds ratio of at least 2 ... decL2(post2, post1) #> [1] 1 # ... but not more than 3 decL3(post2, post1) #> [1] 0"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Boundary for 2 Sample Designs — decision2S_boundary","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"decision2S_boundary function defines 2 sample design (priors, sample sizes, decision function) calculation decision boundary. function returned calculates critical value first sample \\(y_{1,c}\\) function outcome second sample \\(y_2\\). decision boundary, decision function change 0 (failure) 1 (success) respective outcomes.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"","code":"decision2S_boundary(prior1, prior2, n1, n2, decision, ...) # S3 method for class 'betaMix' decision2S_boundary(prior1, prior2, n1, n2, decision, eps, ...) # S3 method for class 'normMix' decision2S_boundary( prior1, prior2, n1, n2, decision, sigma1, sigma2, eps = 1e-06, Ngrid = 10, ... ) # S3 method for class 'gammaMix' decision2S_boundary(prior1, prior2, n1, n2, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"prior1 Prior sample 1. prior2 Prior sample 2. n1, n2 Sample size respective samples. Sample size n1 must greater 0 sample size n2 must greater equal 0. decision Two-sample decision function use; see decision2S. ... Optional arguments. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\). sigma1 fixed reference scale sample 1. left unspecified, default reference scale prior 1 assumed. sigma2 fixed reference scale sample 2. left unspecified, default reference scale prior 2 assumed. Ngrid Determines density discretization grid decision function evaluated (see details).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"Returns function single argument. function calculates dependence outcome \\(y_2\\) sample 2 critical value \\(y_{1,c}\\) defined design change decision 0 1 (vice versa, depending decision function).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"2 sample design specification priors, sample sizes decision function, \\(D(y_1,y_2)\\), uniquely defines decision boundary $$D_1(y_2) = \\max_{y_1}\\{D(y_1,y_2) = 1\\},$$ critical value \\(y_{1,c}\\) conditional value \\(y_2\\) whenever decision \\(D(y_1,y_2)\\) function changes value 0 1 decision function lower.tail=TRUE (otherwise definition \\(D_1(y_2) = \\max_{y_1}\\{D(y_1,y_2) = 0\\}\\)). decision function may change single critical value given \\(y_{2}\\) one-sided decision functions supported. , \\(y_2\\) defined binary Poisson endpoints sufficient statistic \\(y_2 = \\sum_{=1}^{n_2} y_{2,}\\) normal case mean \\(\\bar{y}_2 = 1/n_2 \\sum_{=1}^{n_2} y_{2,}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"decision2S_boundary(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. optional argument eps defined, approximate method used limits search decision boundary region 1-eps probability mass. useful designs large sample sizes exact approach costly calculate. decision2S_boundary(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture priors means. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function two extra arguments (defaults): eps (\\(10^{-6}\\)) Ngrid (10). decision boundary searched region probability mass 1-eps, respectively \\(y_1\\) \\(y_2\\). continuous decision function evaluated discrete grid, determined spacing \\(\\delta_2 = \\sigma_2/\\sqrt{N_{grid}}\\). decision boundary evaluated discrete steps, spline used inter-polate decision boundary intermediate points. decision2S_boundary(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function decision2S_boundary takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y_1\\) \\(y_2\\), respectively.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"","code":"# see ?decision2S for details of example priorT <- mixnorm(c(1, 0, 0.001), sigma = 88, param = \"mn\") priorP <- mixnorm(c(1, -49, 20), sigma = 88, param = \"mn\") # the success criteria is for delta which are larger than some # threshold value which is why we set lower.tail=FALSE successCrit <- decision2S(c(0.95, 0.5), c(0, 50), FALSE) # the futility criterion acts in the opposite direction futilityCrit <- decision2S(c(0.90), c(40), TRUE) # success criterion boundary successBoundary <- decision2S_boundary(priorP, priorT, 10, 20, successCrit) #> Using default prior 1 reference scale 88 #> Using default prior 2 reference scale 88 # futility criterion boundary futilityBoundary <- decision2S_boundary(priorP, priorT, 10, 20, futilityCrit) #> Using default prior 1 reference scale 88 #> Using default prior 2 reference scale 88 curve(successBoundary(x), -25:25 - 49, xlab = \"y2\", ylab = \"critical y1\") curve(futilityBoundary(x), lty = 2, add = TRUE) # hence, for mean in sample 2 of 10, the critical value for y1 is y1c <- futilityBoundary(-10) # around the critical value the decision for futility changes futilityCrit(postmix(priorP, m = y1c + 1E-3, n = 10), postmix(priorT, m = -10, n = 20)) #> Using default prior reference scale 88 #> Using default prior reference scale 88 #> [1] 0 futilityCrit(postmix(priorP, m = y1c - 1E-3, n = 10), postmix(priorT, m = -10, n = 20)) #> Using default prior reference scale 88 #> Using default prior reference scale 88 #> [1] 1"},{"path":"https://opensource.nibr.com/RBesT/reference/dlink-set.html","id":null,"dir":"Reference","previous_headings":"","what":"Transform Densities with a link function — dlink<-","title":"Transform Densities with a link function — dlink<-","text":"One--one transforms (mixture) densities using link function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/dlink-set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transform Densities with a link function — dlink<-","text":"","code":"dlink(object) <- value"},{"path":"https://opensource.nibr.com/RBesT/reference/dlink-set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Transform Densities with a link function — dlink<-","text":"object Mixture density apply link . value Link. Note: link functions assumed order preserving, .e. x_1 < x_2 holds, link(x_1) < link(x_2).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":null,"dir":"Reference","previous_headings":"","what":"Effective Sample Size for a Conjugate Prior — ess","title":"Effective Sample Size for a Conjugate Prior — ess","text":"Calculates Effective Sample Size (ESS) mixture prior. ESS indicates many experimental units prior roughly equivalent .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Effective Sample Size for a Conjugate Prior — ess","text":"","code":"ess(mix, method = c(\"elir\", \"moment\", \"morita\"), ...) # S3 method for class 'betaMix' ess(mix, method = c(\"elir\", \"moment\", \"morita\"), ..., s = 100) # S3 method for class 'gammaMix' ess(mix, method = c(\"elir\", \"moment\", \"morita\"), ..., s = 100, eps = 1e-04) # S3 method for class 'normMix' ess( mix, method = c(\"elir\", \"moment\", \"morita\"), ..., family = gaussian, sigma, s = 100 )"},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Effective Sample Size for a Conjugate Prior — ess","text":"mix Prior (mixture conjugate distributions). method Selects used method. Can either elir (default), moment morita. ... Optional arguments applicable specific methods. s morita method large constant ensure prior scaled value vague (default 100); see Morita et al. (2008) details. eps Probability mass left numerical integration expected information Poisson-Gamma case Morita method (defaults 1E-4). family defines data likelihood link function (binomial, gaussian, poisson). sigma reference scale.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Effective Sample Size for a Conjugate Prior — ess","text":"Returns ESS prior floating point number.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Effective Sample Size for a Conjugate Prior — ess","text":"ESS calculated using either expected local information ratio (elir) Neuenschwander et al. (2020), moments approach method Morita et al. (2008). elir approach measures effective sample size terms average curvature prior relation Fisher information. Informally corresponds average peakiness prior relation information content single observation. elir approach ESS fulfills predictive consistency. predictive consistency ESS requires ESS prior consistent considering averaged posterior ESS additional data distributed according predictive distribution prior. expectation posterior ESS taken wrt prior predictive distribution averaged posterior ESS corresponds sum prior ESS number forward simulated data items. elir approach results ESS estimates neither conservative liberal whereas moments method yields conservative morita method liberal results. See example section demonstration predictive consistency. moments method mean standard deviation mixture calculated approximated conjugate distribution mean standard deviation. conjugate distributions, ESS well defined. See examples step-wise calculation beta mixture case. Morita method used evaluates mixture prior mode instead mean proposed originally Morita. method may lead optimistic ESS values, especially mixture contains many components. calculation Morita approach follows approach presented Neuenschwander B. et (2019) avoids need minimization restrict ESS integer. arguments sigma family specific normal mixture densities. specify sampling standard deviation gaussian family (default) also allowing consider ESS standard one-parameter exponential families, .e. binomial poisson. function supports non-gaussian families unit dispersion .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Effective Sample Size for a Conjugate Prior — ess","text":"ess(betaMix): ESS beta mixtures. ess(gammaMix): ESS gamma mixtures. ess(normMix): ESS normal mixtures.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Effective Sample Size for a Conjugate Prior — ess","text":"Morita S, Thall PF, Mueller P. Determining effective sample size parametric prior. Biometrics 2008;64(2):595-602. Neuenschwander B., Weber S., Schmidli H., O’Hagan . (2020). Predictively consistent prior effective sample sizes. Biometrics, 76(2), 578–587. https://doi.org/10.1111/biom.13252","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Effective Sample Size for a Conjugate Prior — ess","text":"","code":"# Conjugate Beta example a <- 5 b <- 15 prior <- mixbeta(c(1, a, b)) ess(prior) #> [1] 20 (a + b) #> [1] 20 # Beta mixture example bmix <- mixbeta(rob = c(0.2, 1, 1), inf = c(0.8, 10, 2)) ess(bmix, \"elir\") #> [1] 7.65152 ess(bmix, \"moment\") #> [1] 3.161034 # moments method is equivalent to # first calculate moments bmix_sum <- summary(bmix) # then calculate a and b of a matching beta ab_matched <- ms2beta(bmix_sum[\"mean\"], bmix_sum[\"sd\"]) # finally take the sum of a and b which are equivalent # to number of responders/non-responders respectivley round(sum(ab_matched)) #> [1] 3 ess(bmix, method = \"morita\") #> [1] 8.487603 # One may also calculate the ESS on the logit scale, which # gives slightly different results due to the parameter # transformation, e.g.: prior_logit <- mixnorm(c(1, log(5 / 15), sqrt(1 / 5 + 1 / 15))) ess(prior_logit, family = binomial) #> [1] 21.78289 bmix_logit <- mixnorm(rob = c(0.2, 0, 2), inf = c(0.8, log(10 / 2), sqrt(1 / 10 + 1 / 2))) ess(bmix_logit, family = binomial) #> [1] 10.12276 # Predictive consistency of elir n_forward <- 1E1 bmixPred <- preddist(bmix, n = n_forward) pred_samp <- rmix(bmixPred, 1E2) # use more samples here for greater accuracy, e.g. # pred_samp <- rmix(bmixPred, 1E3) pred_ess <- sapply(pred_samp, function(r) ess(postmix(bmix, r = r, n = n_forward), \"elir\")) ess(bmix, \"elir\") #> [1] 7.65152 mean(pred_ess) - n_forward #> [1] 7.071933 # Normal mixture example nmix <- mixnorm(rob = c(0.5, 0, 2), inf = c(0.5, 3, 4), sigma = 10) ess(nmix, \"elir\") #> Using default prior reference scale 10 #> [1] 10.82796 ess(nmix, \"moment\") #> Using default prior reference scale 10 #> [1] 8.163265 # the reference scale determines the ESS sigma(nmix) <- 20 ess(nmix) #> Using default prior reference scale 20 #> [1] 43.31185 # we may also interpret normal mixtures as densities assigned to # parameters of a logit transformed response rate of a binomial nmix_logit <- mixnorm(c(1, logit(1 / 4), 2 / sqrt(10))) ess(nmix_logit, family = binomial) #> [1] 15.17836 # Gamma mixture example gmix <- mixgamma(rob = c(0.3, 20, 4), inf = c(0.7, 50, 10)) ess(gmix) ## interpreted as appropriate for a Poisson likelihood (default) #> [1] 7.159378 likelihood(gmix) <- \"exp\" ess(gmix) ## interpreted as appropriate for an exponential likelihood #> [1] 34.93388"},{"path":"https://opensource.nibr.com/RBesT/reference/fill.html","id":null,"dir":"Reference","previous_headings":"","what":"Fill numeric objects — fill","title":"Fill numeric objects — fill","text":"Returns numeric input object value given respects dimensionalty type input.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/fill.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fill numeric objects — fill","text":"","code":"fill(x, value)"},{"path":"https://opensource.nibr.com/RBesT/reference/fill.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fill numeric objects — fill","text":"x Input numeric object. value Value filled.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":null,"dir":"Reference","previous_headings":"","what":"Forest Plot — forest_plot","title":"Forest Plot — forest_plot","text":"Creates forest plot gMAP analysis objects.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Forest Plot — forest_plot","text":"","code":"forest_plot( x, prob = 0.95, est = c(\"both\", \"MAP\", \"Mean\", \"none\"), model = c(\"stratified\", \"both\", \"meta\"), point_est = c(\"median\", \"mean\"), size = 1.25, alpha = 0.5 )"},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Forest Plot — forest_plot","text":"x gMAP object. prob confidence interval width probability mass credible intervals. est can set one (default), MAP, Mean none. Controls model estimates included. model controls estimates displayed per study. Either stratified (default), meta. point_est shown point estimate. Either median (default) mean. size controls point linesize. alpha transparency reference line. Setting alpha=0 suppresses reference line.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Forest Plot — forest_plot","text":"function returns ggplot2 plot object.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Forest Plot — forest_plot","text":"function creates forest plot suitable gMAP analyses. Note Meta-Analytic-Predictive prior included default plot opposed showing estimated model mean. See examples obtain standard forest plots. Also note plot internally flips x y-axis. Therefore, want manipulate x-axis, give commands affecting y-axis (see examples).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Forest Plot — forest_plot","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Forest Plot — forest_plot","text":"","code":"# we consider the example AS MAP analysis example(AS) #> #> AS> ## Setting up dummy sampling for fast execution of example #> AS> ## Please use 4 chains and 20x more warmup & iter in practice #> AS> .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, #> AS+ RBesT.MC.chains=2, RBesT.MC.thin=1) #> #> AS> set.seed(34563) #> #> AS> map_AS <- gMAP(cbind(r, n - r) ~ 1 | study, #> AS+ family = binomial, #> AS+ data = AS, #> AS+ tau.dist = \"HalfNormal\", tau.prior = 1, #> AS+ beta.prior = 2 #> AS+ ) #> Assuming default prior location for beta: 0 #> Warning: The largest R-hat is 1.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Warning: Maximal Rhat > 1.1. Consider increasing RBesT.MC.warmup MCMC parameter. #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. #> #> AS> ## Recover user set sampling defaults #> AS> options(.user_mc_options) # default forest plot for a gMAP analysis forest_plot(map_AS) # standard forest plot (only stratified estimate and Mean) forest_plot(map_AS, est = c(\"Mean\"), model = \"stratified\") # to further customize these plots, first load bayesplot and ggplot2 library(bayesplot) #> This is bayesplot version 1.11.1 #> - Online documentation and vignettes at mc-stan.org/bayesplot #> - bayesplot theme set to bayesplot::theme_default() #> * Does _not_ affect other ggplot2 plots #> * See ?bayesplot_theme_set for details on theme setting library(ggplot2) # to make plots with red colors, big fonts for presentations, suppress # the x axis label and add another title (with a subtitle) color_scheme_set(\"red\") theme_set(theme_default(base_size = 16)) forest_plot(map_AS, size = 2) + yaxis_title(FALSE) + ggtitle(\"Ankylosing Spondylitis Forest Plot\", subtitle = \"Control Group Response Rate\" ) # the defaults are set with color_scheme_set(\"blue\") theme_set(theme_default(base_size = 12))"},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":null,"dir":"Reference","previous_headings":"","what":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"Meta-Analytic-Predictive (MAP) analysis generalized linear models suitable normal, binary, Poisson data. Model specification overall syntax follows mainly glm conventions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"","code":"gMAP( formula, family = gaussian, data, weights, offset, tau.strata, tau.dist = c(\"HalfNormal\", \"TruncNormal\", \"Uniform\", \"Gamma\", \"InvGamma\", \"LogNormal\", \"TruncCauchy\", \"Exp\", \"Fixed\"), tau.prior, tau.strata.pred = 1, beta.prior, prior_PD = FALSE, REdist = c(\"normal\", \"t\"), t.df = 5, contrasts = NULL, iter = getOption(\"RBesT.MC.iter\", 6000), warmup = getOption(\"RBesT.MC.warmup\", 2000), thin = getOption(\"RBesT.MC.thin\", 4), init = getOption(\"RBesT.MC.init\", 1), chains = getOption(\"RBesT.MC.chains\", 4), cores = getOption(\"mc.cores\", 1L) ) # S3 method for class 'gMAP' print(x, digits = 3, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gMAP' fitted(object, type = c(\"response\", \"link\"), probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gMAP' coef(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gMAP' as.matrix(x, ...) # S3 method for class 'gMAP' summary( object, type = c(\"response\", \"link\"), probs = c(0.025, 0.5, 0.975), ... )"},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"formula model formula describing linear predictor encoding grouping; see details family defines data likelihood link function (binomial, gaussian, poisson) data optional data frame containing variables model. found data, variables taken environment(formula). weights optional weight vector; see details . offset offset term statistical model used Poisson data tau.strata sets exchangability stratum per study. , expected study belongs single stratum. Default assign studies stratum 1. See section differential heterogeniety . tau.dist type prior distribution tau; supported priors HalfNormal (default), TruncNormal, Uniform, Gamma, InvGamma, LogNormal, TruncCauchy, Exp Fixed. tau.prior parameters prior distribution tau; see section prior specification . tau.strata.pred index prediction stratum; default 1. beta.prior mean standard deviation normal priors regression coefficients, see section prior specification . prior_PD logical indicate prior predictive distribution sampled (conditioning data). Defaults FALSE. REdist type random effects distribution. Normal (default) t. t.df degrees freedom random-effects distribution t. contrasts optional list; See contrasts.arg model.matrix.default. iter number iterations (including warmup). warmup number warmup iterations. thin period saving samples. init positive number specify uniform range unconstrained space random initialization. See stan. chains number Markov chains. cores number cores parallel sampling chains. x, object gMAP analysis object created gMAP function digits number displayed significant digits. probs defines quantiles reported. ... optional arguments ignored type sets reported scale (response (default) link).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"function returns S3 object type gMAP. See methods section applicable functions query object.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"meta-analytic-predictive (MAP) approach derives prior historical data using hierarchical model. statistical model formulated generalized linear mixed model binary, normal (fixed \\(\\sigma\\)) Poisson endpoints: $$y_{ih}|\\theta_{ih} \\sim f(y_{ih} | \\theta_{ih})$$ , \\(=1,\\ldots,N\\) index observations, \\(h=1,\\ldots,H\\) index grouping (usually studies). model assumes linear predictor transformed mean $$g(\\theta_{ih}; x_{ih},\\beta) = x_{ih} \\, \\beta + \\epsilon_h$$ \\(x_{ih}\\) row vector \\(k\\) covariates observation \\(\\). variance component assumed default normal $$\\epsilon_h \\sim N(0,\\tau^2), \\qquad h=1,\\ldots,H$$ Lastly, Bayesian implementation assumes independent normal priors \\(k\\) regression coefficients prior -group standard deviation \\(\\tau\\) (see taud.dist available distributions). MAP prior derived model conditional distribution \\(\\theta_{\\star}\\) given available data vector covariates \\(x_{\\star}\\) defining overall intercept $$\\theta_{\\star}| x_{\\star},y .$$ simple common case arises one observation (summary statistic) per trial. normal endpoint, model simplifies standard normal-normal hierarchical model. notation, \\(=h=1,\\ldots,H\\) $$y_h|\\theta_h \\sim N(\\theta_h,s_h^2)$$ $$\\theta_h = \\mu + \\epsilon_h$$ $$\\epsilon_h \\sim N(0,\\tau^2),$$ common \\(\\mu\\) used (intercept) parameter \\(\\beta_1\\). Since covariates, MAP prior simply \\(Pr(\\theta_{\\star} | y_1,\\ldots,y_H)\\). hierarchical model compromise two extreme cases full pooling (\\(\\tau=0\\), full borrowing, discounting) pooling (\\(\\tau=\\infty\\), borrowing, stratification). information content historical data grows H (number historical data items) indefinitely full pooling whereas information gained stratified analysis. fixed \\(\\tau\\), maximum effective sample size MAP prior \\(n_\\infty\\) (\\(H\\rightarrow \\infty\\)), normal endpoint fixed \\(\\sigma\\) $$n_\\infty = \\left(\\frac{\\tau^2}{\\sigma^2}\\right)^{-1},$$ (Neuenschwander et al., 2010). Hence, ratio \\(\\tau/\\sigma\\) limits amount information MAP prior equivalent . allows classification \\(\\tau\\) values relation \\(\\sigma\\), crucial define prior \\(P_\\tau\\). following classification useful clinical trial setting: formula \\(n_\\infty\\) assumes known \\(\\tau\\). unrealistic -trial heterogeneity parameter often well estimable, particular number trials small (H small). table helps specify prior distribution \\(\\tau\\) appropriate given context defines crucial parameter \\(\\sigma\\). binary Poisson endpoints, normal approximations can used determine \\(\\sigma\\). See examples concrete cases. design matrix \\(X\\) defined formula linear predictor always form response ~ predictor | grouping, follows glm conventions. syntax extended include specification grouping (example study) factor data horizontal bar, |. bar separates optionally specified grouping level, .e. binary endpoint case cbind(r, n-r) ~ 1 | study. default assumed row corresponds individual group (individual parameter estimated). Specifics different endpoints : normal family=gaussian assumes identity link function. response given matrix two columns first column observed mean value \\(y_{ih}\\) second column standard error \\(se_{ih}\\) (mean). Additionally, recommended specify weight argument number units contributed (mean) measurement \\(y_{ih}\\). information used estimate \\(\\sigma\\). binary family=binomial assumes logit link function. response must given two-column matrix number responders \\(r\\) (first column) non-responders \\(n-r\\) (second column). Poisson family=poisson assumes log link function. response vector counts. total exposure times can specified offset, linearly added linear predictor. offset can given part formula, y ~ 1 + offset(log(exposure)) offset argument gMAP. Note exposure unit must given log-offset.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"methods-by-generic-","dir":"Reference","previous_headings":"","what":"Methods (by generic)","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"print(gMAP): displays summary gMAP analysis. fitted(gMAP): returns quantiles posterior shrinkage estimates data item used analysis given gMAP object. coef(gMAP): returns quantiles predictive distribution. User can choose type result response link scale. .matrix(gMAP): extracts posterior sample model. summary(gMAP): returns summaries gMAP. analysis. Output gMAPsummary object, list containing tau posterior summary heterogeneity standard deviation beta posterior summary regression coefficients theta.pred summary predictive distribution (given dependence type argument either response link scale) theta posterior summary mean estimate (also depends type argument)","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"differential-discounting","dir":"Reference","previous_headings":"","what":"Differential Discounting","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"model assumes -group standard deviation \\(\\tau\\), implies data equally relevant. assumption can relaxed one \\(\\tau\\). , $$\\epsilon_h \\sim N(0,\\tau_{s(h)}^2)$$ \\(s(h)\\) assignes group \\(h\\) one \\(S\\) -group heterogeneity strata. example, situation two randomized four observational studies, one may want assume \\(\\tau_1\\) (trials 1 2) \\(\\tau_2\\) (trials 3-6) -trial standard deviations control means. heterogeneity (less relevance) observational studies can expressed appropriate priors \\(\\tau_1\\) \\(\\tau_2\\). case, \\(S=2\\) strata assignments (see tau.strata argument) \\(s(1)=s(2)=1, s(3)=\\ldots=s(6)=2\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"prior-specification","dir":"Reference","previous_headings":"","what":"Prior Specification","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"prior distribution regression coefficients \\(\\beta\\) normal. single number given, used standard deviation default mean 0 used. vector given, must length number covariates defined used standard deviation. matrix single row given, first row used mean second row used standard deviation regression coefficients. Lastly, two-column matrix (mean standard deviation columns) many columns regression coefficients can given. recommended always specify beta.prior. Per default mean 0 set. standard deviation set 2 binary case, 100 * sd(y) normal case sd(log(y + 0.5 + offset)) Poisson case. -trial heterogeniety \\(\\tau\\) prior, dispersion parameter must always given exchangeability stratum. different tau.prior distributions, two parameters needed one set default value applicable: prior distribution default location parameter, vector length equal number exchangability strata can given. Otherwise, two-column matrix many rows exchangability strata must given, except single \\(\\tau\\) stratum, vector length two defines parameters b.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"random-seed","dir":"Reference","previous_headings":"","what":"Random seed","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"MAP analysis performed using Markov-Chain-Monte-Carlo (MCMC) rstan. MCMC stochastic algorithm. obtain exactly reproducible results must use set.seed function calling gMAP. See RBesT overview page global options setting MCMC simulation parameters.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"Neuenschwander B, Capkun-Niggli G, Branson M, Spiegelhalter DJ. Summarizing historical information controls clinical trials. Clin Trials. 2010; 7(1):5-18 Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032. Weber S, Li Y, Seaman III J.W., Kakizume T, Schmidli H. Applying Meta-Analytic Predictive Priors R Bayesian evidence synthesis tools. JSS 2021; 100(19):1-32","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) # Binary data example 1 # Mean response rate is ~0.25. For binary endpoints # a conservative choice for tau is a HalfNormal(0,1) as long as # the mean response rate is in the range of 0.2 to 0.8. For # very small or large rates consider the n_infinity approach # illustrated below. # for exact reproducible results, the seed must be set set.seed(34563) map_AS <- gMAP(cbind(r, n - r) ~ 1 | study, family = binomial, data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2 ) #> Assuming default prior location for beta: 0 #> Warning: The largest R-hat is 1.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Warning: Maximal Rhat > 1.1. Consider increasing RBesT.MC.warmup MCMC parameter. #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. print(map_AS) #> Generalized Meta Analytic Predictive Prior Analysis #> #> Call: gMAP(formula = cbind(r, n - r) ~ 1 | study, family = binomial, #> data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2) #> #> Exchangeability tau strata: 1 #> Prediction tau stratum : 1 #> Maximal Rhat : 1.11 #> #> Between-trial heterogeneity of tau prediction stratum #> mean sd 2.5% 50% 97.5% #> 0.370 0.163 0.110 0.352 0.764 #> #> MAP Prior MCMC sample #> mean sd 2.5% 50% 97.5% #> 0.2580 0.0817 0.1230 0.2510 0.4460 #> Warning: Parts of the model have not converged (some Rhats are > 1.1). #> Be careful when analysing the results! It is recommend to run #> more iterations and/or setting stronger priors. # obtain numerical summaries map_sum <- summary(map_AS) print(map_sum) #> Heterogeneity parameter tau per stratum: #> mean sd 2.5% 50% 97.5% #> tau[1] 0.37 0.163 0.11 0.352 0.764 #> #> Regression coefficients: #> mean sd 2.5% 50% 97.5% #> (Intercept) -1.12 0.178 -1.47 -1.11 -0.767 #> #> Mean estimate MCMC sample: #> mean sd 2.5% 50% 97.5% #> theta_resp 0.248 0.033 0.187 0.247 0.317 #> #> MAP Prior MCMC sample: #> mean sd 2.5% 50% 97.5% #> theta_resp_pred 0.258 0.0817 0.123 0.251 0.446 names(map_sum) #> [1] \"tau\" \"beta\" \"theta.pred\" \"theta\" # [1] \"tau\" \"beta\" \"theta.pred\" \"theta\" map_sum$theta.pred #> mean sd 2.5% 50% 97.5% #> theta_resp_pred 0.2576768 0.08166927 0.1232554 0.2508299 0.4464658 # \\donttest{ # graphical model checks (returns list of ggplot2 plots) map_checks <- plot(map_AS) # forest plot with shrinkage estimates map_checks$forest_model # density of MAP prior on response scale map_checks$densityThetaStar # density of MAP prior on link scale map_checks$densityThetaStarLink # } # obtain shrinkage estimates fitted(map_AS) #> mean sd 2.5% 50% 97.5% #> Study 1 0.2245230 0.03009877 0.16467408 0.2255518 0.2698386 #> Study 2 0.2600974 0.05160094 0.17318985 0.2610201 0.3745415 #> Study 3 0.3157218 0.06628311 0.21188389 0.3041774 0.4656744 #> Study 4 0.2440305 0.04812868 0.15154707 0.2442546 0.3333963 #> Study 5 0.2681039 0.03179363 0.21285005 0.2633981 0.3412085 #> Study 6 0.2670423 0.05109495 0.19112391 0.2609730 0.3660353 #> Study 7 0.1704818 0.04185255 0.08821842 0.1727647 0.2466163 #> Study 8 0.2649455 0.04246509 0.20001270 0.2574109 0.3462487 # regression coefficients coef(map_AS) #> mean sd 2.5% 50% 97.5% #> (Intercept) -1.11748 0.1782488 -1.468582 -1.113787 -0.7667301 # finally fit MAP prior with parametric mixture map_mix <- mixfit(map_AS, Nc = 2) plot(map_mix)$mix # \\donttest{ # optionally select number of components automatically via AIC map_automix <- automixfit(map_AS) plot(map_automix)$mix # } # Normal example 2, see normal vignette # Prior considerations # The general principle to derive a prior for tau can be based on the # n_infinity concept as discussed in Neuenschwander et al., 2010. # This assumes a normal approximation which applies for the colitis # data set as: p_bar <- mean(with(colitis, r / n)) s <- round(1 / sqrt(p_bar * (1 - p_bar)), 1) # s is the approximate sampling standard deviation and a # conservative prior is tau ~ HalfNormal(0,s/2) tau_prior_sd <- s / 2 # Evaluate HalfNormal prior for tau tau_cat <- c( pooling = 0, small = 0.0625, moderate = 0.125, substantial = 0.25, large = 0.5, veryLarge = 1, stratified = Inf ) # Interval probabilites (basically saying we are assuming # heterogeniety to be smaller than very large) diff(2 * pnorm(tau_cat * s, 0, tau_prior_sd)) #> small moderate substantial large veryLarge stratified #> 0.09947645 0.09793620 0.18551227 0.29976457 0.27181024 0.04550026 # Cumulative probabilities as 1-F 1 - 2 * (pnorm(tau_cat * s, 0, tau_prior_sd) - 0.5) #> pooling small moderate substantial large veryLarge #> 1.00000000 0.90052355 0.80258735 0.61707508 0.31731051 0.04550026 #> stratified #> 0.00000000 ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/integrate_density_log.html","id":null,"dir":"Reference","previous_headings":"","what":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","title":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","text":"integrate density logit space split component quantile function component used. ensures R implementation quantile function always used.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/integrate_density_log.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","text":"","code":"integrate_density_log( log_integrand, mix, Lplower = -Inf, Lpupper = Inf, eps = getOption(\"RBesT.integrate_prob_eps\", 1e-06) )"},{"path":"https://opensource.nibr.com/RBesT/reference/integrate_density_log.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","text":"log_integrand function integrate must return log(f) mix density integrate Lplower logit lower cumulative density Lpupper logit upper cumulative density","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/knn.html","id":null,"dir":"Reference","previous_headings":"","what":"k nearest neighbor algorithm for multi-variate data — knn","title":"k nearest neighbor algorithm for multi-variate data — knn","text":"k nearest neighbor algorithm multi-variate data","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/knn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"k nearest neighbor algorithm for multi-variate data — knn","text":"","code":"knn(X, K = 2, init, Ninit = 50, verbose = FALSE, tol, Niter.max = 500)"},{"path":"https://opensource.nibr.com/RBesT/reference/knn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"k nearest neighbor algorithm for multi-variate data — knn","text":"X data matrix, .e. observations X dimensions K number clusters use init list p mu used initialization Ninit number samples used per cluster init argument given verbose allows print progress information; verbose mode cluster memberships added output tol smaller changes tol objective function indicate convergence, missing chosen automatically 1/5 smallest sample variance per dimension Niter.max maximum number admissible iterations","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":null,"dir":"Reference","previous_headings":"","what":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"Read set likelihood distribution corresponding conjugate prior distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"","code":"likelihood(mix) likelihood(mix) <- value"},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"mix Prior mixture distribution. value New likelihood. changed Gamma priors supported either Poisson (value=\"poisson\") Exponential (value=\"exp\") likelihoods.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"prior posterior distributions family, prior distribution called conjugate prior likelihood function.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"","code":"# Gamma mixture gmix <- mixgamma(c(0.3, 20, 4), c(0.7, 50, 10)) # read out conjugate partner likelihood(gmix) #> [1] \"poisson\" ess(gmix) #> [1] 7.159378 # set conjugate partner likelihood(gmix) <- \"exp\" # ... which changes the interpretation of the mixture ess(gmix) #> [1] 34.93388"},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":null,"dir":"Reference","previous_headings":"","what":"Logit (log-odds) and inverse-logit function. — lodds","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"Calculates logit (log-odds) inverse-logit.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"","code":"logit(mu) inv_logit(eta)"},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"mu numeric object probabilies, values range [0,1]. Missing values (NAs) allowed. eta numeric object log-odds values, values range [-Inf,Inf]. Missing values (NAs) allowed.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"numeric object type mu eta containing logits inverse logit input values. logit inverse transformation equates $$\\mbox{logit}(\\mu) = \\log(\\mu/(1-\\mu))$$ $$\\mbox{logit}^{-1}(\\eta)= \\exp(\\eta)/(1 + \\exp(\\eta)).$$","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"Values mu equal 0 1 return -Inf Inf respectively.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"","code":"logit(0.2) #> [1] -1.386294 inv_logit(-1.386) #> [1] 0.2000471"},{"path":"https://opensource.nibr.com/RBesT/reference/logLik.EM.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract log likelihood from fitted EM objects — logLik.EM","title":"Extract log likelihood from fitted EM objects — logLik.EM","text":"Extract log likelihood fitted EM objects","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/logLik.EM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract log likelihood from fitted EM objects — logLik.EM","text":"","code":"# S3 method for class 'EM' logLik(object, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/log_inv_logit.html","id":null,"dir":"Reference","previous_headings":"","what":"Numerically stable log of the inv_logit function — log_inv_logit","title":"Numerically stable log of the inv_logit function — log_inv_logit","text":"Numerically stable log inv_logit function","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/log_inv_logit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Numerically stable log of the inv_logit function — log_inv_logit","text":"","code":"log_inv_logit(mat)"},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":null,"dir":"Reference","previous_headings":"","what":"Mixture Distributions — mix","title":"Mixture Distributions — mix","text":"Density, cumulative distribution function, quantile function random number generation supported mixture distributions. (d/p/q/r)mix generic work mixture supported BesT (see table ).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mixture Distributions — mix","text":"","code":"dmix(mix, x, log = FALSE) pmix(mix, q, lower.tail = TRUE, log.p = FALSE) qmix(mix, p, lower.tail = TRUE, log.p = FALSE) rmix(mix, n) # S3 method for class 'mix' mix[[..., rescale = FALSE]]"},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mixture Distributions — mix","text":"mix mixture distribution object x, q vector quantiles log, log.p logical; TRUE (default), probabilities \\(p\\) given \\(\\log(p)\\) lower.tail logical; TRUE (default), probabilities \\(P[X\\leq x]\\) otherwise, \\(P[X>x]\\) p vector probabilities n number observations. length(n) > 1, length taken number required ... components subset given mixture. rescale logical; TRUE, mixture weights rescaled sum 1","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mixture Distributions — mix","text":"dmix gives weighted sum densities component. pmix calculates distribution function evaluating weighted sum components distribution function. qmix returns quantile given p using distribution function monotonous hence gradient based minimization scheme can used find matching quantile q. rmix generates random sample size n first sampling latent component indicator range \\(1..K\\) draw function samples component random draw using respective sampling function. rnorm function returns random draws numerical vector additional attribute ind gives sampled component indicator.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Mixture Distributions — mix","text":"mixture distribution defined linear superposition \\(K\\) densities distributional class. mixture distributions supported form $$f(x,\\mathbf{w},\\mathbf{},\\mathbf{b}) = \\sum_{k=1}^K w_k \\, f_k(x,a_k,b_k).$$ \\(w_k\\) mixing coefficients must sum \\(1\\). Moreover, density \\(f\\) assumed parametrized two parameters component \\(k\\) defined triplet, \\((w_k,a_k,b_k)\\). Individual mixture components can extracted using [[ operator, see examples . supported densities normal, beta gamma can instantiated mixnorm, mixbeta, mixgamma, respectively. addition, respective predictive distributions supported. can obtained calling preddist returns appropriate normal, beta-binomial Poisson-gamma mixtures. convenience summary function defined mixtures. returns mean, standard deviation requested quantiles can specified argument probs.","code":""},{"path":[]},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mixture Distributions — mix","text":"","code":"## a beta mixture bm <- mixbeta(weak = c(0.2, 2, 10), inf = c(0.4, 10, 100), inf2 = c(0.4, 30, 80)) ## extract the two most informative components bm[[c(2, 3)]] #> Univariate beta mixture #> Mixture Components: #> inf inf2 #> w 0.4 0.4 #> a 10.0 30.0 #> b 100.0 80.0 ## rescaling needed in order to plot plot(bm[[c(2, 3), rescale = TRUE]]) summary(bm) #> mean sd 2.5% 50.0% 97.5% #> 0.17878788 0.09898301 0.04389723 0.15654866 0.35327791"},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Beta Mixture Density — mixbeta","title":"Beta Mixture Density — mixbeta","text":"Beta mixture density auxilary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Beta Mixture Density — mixbeta","text":"","code":"mixbeta(..., param = c(\"ab\", \"ms\", \"mn\")) ms2beta(m, s, drop = TRUE) mn2beta(m, n, drop = TRUE) # S3 method for class 'betaMix' print(x, ...) # S3 method for class 'betaBinomialMix' print(x, ...) # S3 method for class 'betaMix' summary(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'betaBinomialMix' summary(object, probs = c(0.025, 0.5, 0.975), ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Beta Mixture Density — mixbeta","text":"... List mixture components. param Determines parameters list interpreted. See details. m Vector means beta mixture components. s Vector standard deviations beta mixture components. drop Delete dimensions array one level. n Vector number observations. x mixture print object Beta mixture object. probs Quantiles reported summary function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Beta Mixture Density — mixbeta","text":"mixbeta returns beta mixture specified mixture components. ms2beta mn2beta return equivalent natural b parametrization given parameters m, s, n.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Beta Mixture Density — mixbeta","text":"entry ... argument list expected triplet numbers defines weight \\(w_k\\), first second parameter mixture component \\(k\\). triplet can optionally named used appropriately. first second parameter can given different parametrizations set param option: ab Natural parametrization Beta density (=shape1 b=shape2). Default. ms Mean standard deviation, \\(m=/(+b)\\) \\(s=\\sqrt{\\frac{m(1-m)}{1+n}}\\), \\(n=+b\\) number observations. Note \\(s\\) must less \\(\\sqrt{m(1-m)}\\). mn Mean number observations, \\(n=+b\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Beta Mixture Density — mixbeta","text":"","code":"## a beta mixture bm <- mixbeta(rob = c(0.2, 2, 10), inf = c(0.4, 10, 100), inf2 = c(0.4, 30, 80)) # mean/standard deviation parametrization bm2 <- mixbeta(rob = c(0.2, 0.3, 0.2), inf = c(0.8, 0.4, 0.01), param = \"ms\") # mean/observations parametrization bm3 <- mixbeta(rob = c(0.2, 0.3, 5), inf = c(0.8, 0.4, 30), param = \"mn\") # even mixed is possible bm4 <- mixbeta(rob = c(0.2, mn2beta(0.3, 5)), inf = c(0.8, ms2beta(0.4, 0.1))) # print methods are defined bm4 #> Univariate beta mixture #> Mixture Components: #> rob inf #> w 0.2 0.8 #> a 1.5 9.2 #> b 3.5 13.8 print(bm4) #> Univariate beta mixture #> Mixture Components: #> rob inf #> w 0.2 0.8 #> a 1.5 9.2 #> b 3.5 13.8"},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine Mixture Distributions — mixcombine","title":"Combine Mixture Distributions — mixcombine","text":"Combining mixture distributions class form new mixture.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine Mixture Distributions — mixcombine","text":"","code":"mixcombine(..., weight, rescale = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine Mixture Distributions — mixcombine","text":"... arbitrary number mixtures distributional class. component values mixture weight model parameters. weight relative weight component new mixture distribution. vector must length input mixtures components. default value gives equal weight component. rescale boolean value indicates weights rescaled sum 1.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine Mixture Distributions — mixcombine","text":"R-object new mixture distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Combine Mixture Distributions — mixcombine","text":"Combines mixtures class random variable form new mixture distribution.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine Mixture Distributions — mixcombine","text":"","code":"# beta with two informative components bm <- mixbeta(inf = c(0.5, 10, 100), inf2 = c(0.5, 30, 80)) # robustified with mixcombine, i.e. a 10% uninformative part added unif <- mixbeta(rob = c(1, 1, 1)) mixcombine(bm, unif, weight = c(9, 1)) #> Univariate beta mixture #> Mixture Components: #> inf inf2 rob #> w 0.45 0.45 0.10 #> a 10.00 30.00 1.00 #> b 100.00 80.00 1.00"},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Difference of mixture distributions — mixdiff","title":"Difference of mixture distributions — mixdiff","text":"Density, cumulative distribution function, quantile function random number generation difference two mixture distributions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Difference of mixture distributions — mixdiff","text":"","code":"dmixdiff(mix1, mix2, x) pmixdiff(mix1, mix2, q, lower.tail = TRUE) qmixdiff(mix1, mix2, p, lower.tail = TRUE) rmixdiff(mix1, mix2, n)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Difference of mixture distributions — mixdiff","text":"mix1 first mixture density mix2 second mixture density x vector values density values computed q vector quantiles cumulative probabilities computed lower.tail logical; TRUE (default), probabilities P[X <= x], otherwise P[X > x]. p vector cumulative probabilities quantiles computed n size random sample","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Difference of mixture distributions — mixdiff","text":"Respective density, quantile, cumulative density random numbers.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Difference of mixture distributions — mixdiff","text":"\\(x_1 \\sim f_1(x_1)\\) \\(x_2 \\sim f_2(x_2)\\), density difference \\(d \\equiv x_1 - x_2\\) given $$f_d(d) = \\int f_1(u) \\, f_2(u - d) \\, du.$$ cumulative distribution function equates $$F_d(d) = \\int f_1(u) \\, (1-F_2(u-d)) \\, du.$$ integrals performed full support densities use numerical integration function integrate.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Difference of mixture distributions — mixdiff","text":"","code":"# 1. Difference between two beta distributions, i.e. Pr( mix1 - mix2 > 0) mix1 <- mixbeta(c(1, 11, 4)) mix2 <- mixbeta(c(1, 8, 7)) pmixdiff(mix1, mix2, 0, FALSE) #> [1] 0.8817696 # Interval probability, i.e. Pr( 0.3 > mix1 - mix2 > 0) pmixdiff(mix1, mix2, 0.3) - pmixdiff(mix1, mix2, 0) #> [1] 0.6005884 # 2. two distributions, one of them a mixture m1 <- mixbeta(c(1, 30, 50)) m2 <- mixbeta(c(0.75, 20, 50), c(0.25, 1, 1)) # random sample of difference set.seed(23434) rM <- rmixdiff(m1, m2, 1E4) # histogram of random numbers and exact density hist(rM, prob = TRUE, new = TRUE, nclass = 40) curve(dmixdiff(m1, m2, x), add = TRUE, n = 51) # threshold probabilities for difference, at 0 and 0.2 pmixdiff(m1, m2, 0) #> [1] 0.2467158 mean(rM < 0) #> [1] 0.2471 pmixdiff(m1, m2, 0.2) #> [1] 0.9025757 mean(rM < 0.2) #> [1] 0.907 # median of difference mdn <- qmixdiff(m1, m2, 0.5) mean(rM < mdn) #> [1] 0.504 # 95%-interval qmixdiff(m1, m2, c(0.025, 0.975)) #> [1] -0.5257954 0.2877204 quantile(rM, c(0.025, 0.975)) #> 2.5% 97.5% #> -0.5232376 0.2862964"},{"path":"https://opensource.nibr.com/RBesT/reference/mixdist3.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to instantiate 2 parameter mixture densities. — mixdist3","title":"Utility function to instantiate 2 parameter mixture densities. — mixdist3","text":"Utility function instantiate 2 parameter mixture densities.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdist3.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to instantiate 2 parameter mixture densities. — mixdist3","text":"","code":"mixdist3(...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit of Mixture Densities to Samples — mixfit","title":"Fit of Mixture Densities to Samples — mixfit","text":"Expectation-Maximization (EM) based fitting parametric mixture densities numerical samples. provides convenient approach approximate MCMC samples parametric mixture distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit of Mixture Densities to Samples — mixfit","text":"","code":"mixfit(sample, type = c(\"norm\", \"beta\", \"gamma\", \"mvnorm\"), thin, ...) # Default S3 method mixfit(sample, type = c(\"norm\", \"beta\", \"gamma\", \"mvnorm\"), thin, ...) # S3 method for class 'gMAP' mixfit(sample, type, thin, ...) # S3 method for class 'gMAPpred' mixfit(sample, type, thin, ...) # S3 method for class 'array' mixfit(sample, type, thin, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit of Mixture Densities to Samples — mixfit","text":"sample Sample fitted. type Mixture density use. Can either norm, beta gamma. thin Thinning applied sample. See description default behavior. ... Parameters passed low-level EM fitting functions. Parameter Nc mandatory.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit of Mixture Densities to Samples — mixfit","text":"mixture object according requested type returned. object additional information attached, .e. log-likelihood can queried diagnostic plots can generated. See links .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fit of Mixture Densities to Samples — mixfit","text":"Parameters EM fitting functions Nc Number mixture components. Required parameter. mix_init Initial mixture density. missing (default) k-nearest-neighbor algorithm used find initial mixture density. Ninit Number data points used initialization. Defaults 50. verbose set TRUE function inform fitting process maxIter Maximal number iterations. Defaults 500. tol Defines convergence criteria upper bound change log-likelihood, .e. derivative (respect iterations) log-likelihood falls tol, function declares convergence stops. eps Must triplet numbers set desired accuracy inferred parameters per mixture component. See description parameters used EM. EM stopped running mean absolute difference last successive Neps estimates given eps parameters. Defaults 5E-3 parameter. Neps Number iterations used running mean parameter estimates test convergence. Defaults 5. constrain_gt1 Logical value controlling Beta EM constrains parameters & b greater 1. default constraints turned (new since 1.6-0). default EM convergence declared desired accuracy parameters reached last Neps estimates. tol Neps specified, whatever criterion met first stop EM. parameters per component \\(k\\) used internally fitting different EM procedures: normal \\(logit(w_k), \\mu_k, \\log(\\sigma_k)\\) beta \\(logit(w_k), \\log(a_k), \\log(b_k)\\) constrained beta \\(logit(w_k), \\log(a_k-1), \\log(b_k-1)\\) gamma \\(logit(w_k), \\log(\\alpha_k), \\log(\\beta_k)\\) Note: Whenever mix_init argument given, EM fitting routines assume data vector given random order. unlikely event EM gets caught local extremum, random reordering data vector may alleviate issue.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Fit of Mixture Densities to Samples — mixfit","text":"mixfit(default): Performs EM fit given sample. Thinning applied thin specified. mixfit(gMAP): Fits default predictive distribution gMAP analysis. Automatically obtains predictive distribution intercept case response scale mixture gMAP object. binomial case beta mixture, gaussian case normal mixture Poisson case gamma mixture used. gaussian case, resulting normal mixture set reference scale estimated sigma gMAP call. mixfit(gMAPpred): Fits mixture density prediction gMAP prediction. mixfit(array): Fits mixture density MCMC sample. recommended provide thinning argument roughly yields independent draws (.e. use acf identify thinning lag small auto-correlation). input array expected 3 dimensions nested iterations, chains, draws.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Fit of Mixture Densities to Samples — mixfit","text":"Dempster .P., Laird N.M., Rubin D.B. Maximum Likelihood Incomplete Data via EM Algorithm. Journal Royal Statistical Society, Series B 1977; 39 (1): 1-38.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fit of Mixture Densities to Samples — mixfit","text":"","code":"bmix <- mixbeta(rob = c(0.2, 1, 1), inf = c(0.8, 10, 2)) bsamp <- rmix(bmix, 1000) bfit <- mixfit(bsamp, type = \"beta\", Nc = 2) # diagnostic plots can easily by generated from the EM fit with bfit.check <- plot(bfit) names(bfit.check) #> [1] \"mixdist\" \"mixdens\" \"mixecdf\" \"mix\" # check convergence of parameters bfit.check$mix bfit.check$mixdens bfit.check$mixecdf # obtain the log-likelihood logLik(bfit) #> 'log Lik.' 543.9702 (df=5) # or AIC AIC(bfit) #> [1] -1077.94"},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":null,"dir":"Reference","previous_headings":"","what":"The Gamma Mixture Distribution — mixgamma","title":"The Gamma Mixture Distribution — mixgamma","text":"gamma mixture density auxiliary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The Gamma Mixture Distribution — mixgamma","text":"","code":"mixgamma(..., param = c(\"ab\", \"ms\", \"mn\"), likelihood = c(\"poisson\", \"exp\")) ms2gamma(m, s, drop = TRUE) mn2gamma(m, n, likelihood = c(\"poisson\", \"exp\"), drop = TRUE) # S3 method for class 'gammaMix' print(x, ...) # S3 method for class 'gammaPoissonMix' print(x, ...) # S3 method for class 'gammaExpMix' print(x, ...) # S3 method for class 'gammaMix' summary(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gammaPoissonMix' summary(object, probs = c(0.025, 0.5, 0.975), ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The Gamma Mixture Distribution — mixgamma","text":"... List mixture components. param Determines parameters list interpreted. See details. likelihood Defines likelihood Gamma density used (Poisson Exp). Defaults poisson. m Vector means Gamma mixture components s Vector standard deviations gamma mixture components, drop Delete dimensions array one level. n Vector sample sizes Gamma mixture components. x mixture print object Gamma mixture object. probs Quantiles reported summary function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The Gamma Mixture Distribution — mixgamma","text":"mixgamma returns gamma mixture specified mixture components. ms2gamma mn2gamma return equivalent natural b parametrization given parameters m, s, n.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"The Gamma Mixture Distribution — mixgamma","text":"entry ... argument list expected triplet numbers defines weight \\(w_k\\), first second parameter mixture component \\(k\\). triplet can optionally named used appropriately. first second parameter can given different parametrizations set param option: ab Natural parametrization Gamma density (=shape b=rate). Default. ms Mean standard deviation, \\(m=/b\\) \\(s=\\sqrt{}/b\\). mn Mean number observations. Translation natural parameter depends likelihood argument. Poisson likelihood \\(n=b\\) (\\(=m \\cdot n\\)), Exp likelihood \\(n=\\) (\\(b=n/m\\)).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"The Gamma Mixture Distribution — mixgamma","text":"","code":"# Gamma mixture with robust and informative component gmix <- mixgamma(rob = c(0.3, 20, 4), inf = c(0.7, 50, 10)) # objects can be printed gmix #> Univariate Gamma mixture #> Mixture Components: #> rob inf #> w 0.3 0.7 #> a 20.0 50.0 #> b 4.0 10.0 # or explicitly print(gmix) #> Univariate Gamma mixture #> Mixture Components: #> rob inf #> w 0.3 0.7 #> a 20.0 50.0 #> b 4.0 10.0 # summaries are defined summary(gmix) #> mean sd 2.5% 50.0% 97.5% #> 5.0000000 0.8514693 3.4362134 4.9560695 6.8210139 # sub-components may be extracted # by component number gmix[[2]] #> Univariate Gamma mixture #> Mixture Components: #> inf #> w 0.7 #> a 50.0 #> b 10.0 # or component name gmix[[\"inf\"]] #> Univariate Gamma mixture #> Mixture Components: #> inf #> w 0.7 #> a 50.0 #> b 10.0 # alternative mean and standard deviation parametrization gmsMix <- mixgamma(rob = c(0.5, 8, 0.5), inf = c(0.5, 9, 2), param = \"ms\") # or mean and number of observations parametrization gmnMix <- mixgamma(rob = c(0.2, 2, 1), inf = c(0.8, 2, 5), param = \"mn\") # and mixed parametrizations are also possible gfmix <- mixgamma(rob1 = c(0.15, mn2gamma(2, 1)), rob2 = c(0.15, ms2gamma(2, 5)), inf = c(0.7, 50, 10))"},{"path":"https://opensource.nibr.com/RBesT/reference/mixlink.html","id":null,"dir":"Reference","previous_headings":"","what":"takes x and transforms it according to the defined link function of the mixture — mixlink","title":"takes x and transforms it according to the defined link function of the mixture — mixlink","text":"takes x transforms according defined link function mixture","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixlink.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"takes x and transforms it according to the defined link function of the mixture — mixlink","text":"","code":"mixlink(mix, x)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":null,"dir":"Reference","previous_headings":"","what":"Multivariate Normal Mixture Density — mixmvnorm","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"multivariate normal mixture density auxiliary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"","code":"mixmvnorm(..., sigma, param = c(\"ms\", \"mn\")) # S3 method for class 'mvnormMix' print(x, ...) # S3 method for class 'mvnormMix' summary(object, ...) # S3 method for class 'mvnormMix' sigma(object, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"... List mixture components. sigma Reference covariance. param Determines parameters list interpreted. See details. x mixture print object Multivariate normal mixture object.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"Returns multivariate normal mixture specified mixture components.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"entry ... argument list numeric vector defining one component mixture multivariate normal distribution. first entry component defining vector weight mixture component followed vector means dimension finally specification covariance matrix, depends chosen parametrization. covariance matrix expected given numeric vector column-major format, standard conversion applied matrices vector concatenation function c. Please refer examples section . component defining vector can specified different ways determined param option: ms Mean vector covariance matrix s. Default. mn Mean vector number observations. n determines covariance component via relation \\(\\Sigma/n\\) \\(\\Sigma\\) known reference covariance. reference covariance \\(\\Sigma\\) known covariance normal-normal model (observation covariance). function sigma can used query reference covariance may also used assign new reference covariance, see examples . case sigma specified, user supply sigma argument functions require reference covariance.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"","code":"S <- diag(c(1, 2)) %*% matrix(c(1, 0.5, 0.5, 1), 2, 2) %*% diag(c(1, 2)) mvnm1 <- mixmvnorm( rob = c(0.2, c(0, 0), diag(c(5, 5))), inf = c(0.8, c(0.5, 1), S / 10), sigma = S ) print(mvnm1) #> Multivariate normal mixture #> Outcome dimension: 2 #> Reference covariance: #> 1 2 #> 1 1 1 #> 2 1 4 #> Mixture Components: #> rob inf #> w 0.2000000 0.8000000 #> m[1] 0.0000000 0.5000000 #> m[2] 0.0000000 1.0000000 #> s[1] 2.2360680 0.3162278 #> s[2] 2.2360680 0.6324555 #> rho[2,1] 0.0000000 0.5000000 summary(mvnm1) #> $mean #> 1 2 #> 0.4 0.8 #> #> $cov #> 1 2 #> 1 1.12 0.16 #> 2 0.16 1.48 #> set.seed(657846) mixSamp1 <- rmix(mvnm1, 500) colMeans(mixSamp1) #> 1 2 #> 0.3695877 0.7900870"},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":null,"dir":"Reference","previous_headings":"","what":"Normal Mixture Density — mixnorm","title":"Normal Mixture Density — mixnorm","text":"normal mixture density auxiliary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Normal Mixture Density — mixnorm","text":"","code":"mixnorm(..., sigma, param = c(\"ms\", \"mn\")) mn2norm(m, n, sigma, drop = TRUE) # S3 method for class 'normMix' print(x, ...) # S3 method for class 'normMix' summary(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'normMix' sigma(object, ...) sigma(object) <- value"},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Normal Mixture Density — mixnorm","text":"... List mixture components. sigma Reference scale. param Determines parameters list interpreted. See details. m Vector means n Vector sample sizes. drop Delete dimensions array one level. x mixture print object Normal mixture object. probs Quantiles reported summary function. value New value reference scale sigma.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Normal Mixture Density — mixnorm","text":"Returns normal mixture specified mixture components. mn2norm returns mean standard deviation given mean sample size parametrization.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Normal Mixture Density — mixnorm","text":"entry ... argument list expected triplet numbers defines weight \\(w_k\\), first second parameter mixture component \\(k\\). triplet can optionally named used appropriately. first second parameter can given different parametrizations set param option: ms Mean standard deviation. Default. mn Mean number observations. n determines s via relation \\(s=\\sigma/\\sqrt{n}\\) \\(\\sigma\\) fixed reference scale. reference scale \\(\\sigma\\) fixed standard deviation one-parameter normal-normal model (observation standard deviation). function sigma can used query reference scale may also used assign new reference scale, see examples . case sigma specified, user supply sigma argument functions require reference scale.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Normal Mixture Density — mixnorm","text":"sigma(object) <- value: Allows assign new reference scale sigma.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Normal Mixture Density — mixnorm","text":"","code":"nm <- mixnorm(rob = c(0.2, 0, 2), inf = c(0.8, 2, 2), sigma = 5) print(nm) #> Univariate normal mixture #> Reference scale: 5 #> Mixture Components: #> rob inf #> w 0.2 0.8 #> m 0.0 2.0 #> s 2.0 2.0 summary(nm) #> mean sd 2.5% 50.0% 97.5% #> 1.600000 2.154066 -2.708104 1.631171 5.740143 plot(nm) set.seed(57845) mixSamp <- rmix(nm, 500) plot(nm, samp = mixSamp) # support defined by quantiles qmix(nm, c(0.01, 0.99)) #> [1] -3.532815 6.491874 # density function dmix(nm, seq(-5, 5, by = 2)) #> [1] 0.002101903 0.019963080 0.087013571 0.176032663 0.153777890 0.053559868 # distribution function pmix(nm, seq(-5, 5, by = 2)) #> [1] 0.001428036 0.018329173 0.115153269 0.385122523 0.739808529 0.945312306 # the reference scale can be changed (it determines the ESS) ess(nm) #> Using default prior reference scale 5 #> [1] 5.404787 sigma(nm) <- 10 ess(nm) #> Using default prior reference scale 10 #> [1] 21.61915"},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot mixture distributions — mixplot","title":"Plot mixture distributions — mixplot","text":"Plotting mixture distributions","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot mixture distributions — mixplot","text":"","code":"# S3 method for class 'mix' plot(x, prob = 0.99, fun = dmix, log = FALSE, comp = TRUE, size = 1.25, ...) # S3 method for class 'mvnormMix' plot(x, prob = 0.99, fun = dmix, log = FALSE, comp = TRUE, size = 1.25, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot mixture distributions — mixplot","text":"x mixture distribution prob defining lower upper percentile x-axis. Defaults 99% central probability mass. fun function plot can dmix, qmix pmix. log log argument passed function specified fun. comp density function can set TRUE display colour-coded mixture component density addition density. size controls linesize plots. ... extra arguments passed plotted function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot mixture distributions — mixplot","text":"ggplot object returned.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot mixture distributions — mixplot","text":"Plot function mixture distribution objects. shows density/quantile/cumulative distribution (corresponds d/q/pmix function) specific central probability mass defined prob. default x-axis chosen show 99% probability density mass.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Plot mixture distributions — mixplot","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot mixture distributions — mixplot","text":"","code":"# beta with two informative components bm <- mixbeta(inf = c(0.5, 10, 100), inf2 = c(0.5, 30, 80)) plot(bm) plot(bm, fun = pmix) # for customizations of the plot we need to load ggplot2 first library(ggplot2) # show a histogram along with the density plot(bm) + geom_histogram( data = data.frame(x = rmix(bm, 1000)), aes(y = ..density..), bins = 50, alpha = 0.4 ) #> Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0. #> ℹ Please use `after_stat(density)` instead. #> ℹ The deprecated feature was likely used in the RBesT package. #> Please report the issue at . # \\donttest{ # note: we can also use bayesplot for histogram plots with a density ... library(bayesplot) mh <- mcmc_hist(data.frame(x = rmix(bm, 1000)), freq = FALSE) + overlay_function(fun = dmix, args = list(mix = bm)) # ...and even add each component for (k in 1:ncol(bm)) { mh <- mh + overlay_function(fun = dmix, args = list(mix = bm[[k]]), linetype = I(2)) } print(mh) #> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. # } # normal mixture nm <- mixnorm(rob = c(0.2, 0, 2), inf = c(0.8, 6, 2), sigma = 5) plot(nm) plot(nm, fun = qmix) # obtain ggplot2 object and change title pl <- plot(nm) pl + ggtitle(\"Normal 2-Component Mixture\")"},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":null,"dir":"Reference","previous_headings":"","what":"Mixture distributions as brms priors — mixstanvar","title":"Mixture distributions as brms priors — mixstanvar","text":"Adapter function converting mixture distributions use brm models via stanvar facility.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mixture distributions as brms priors — mixstanvar","text":"","code":"mixstanvar(..., verbose = FALSE)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mixture distributions as brms priors — mixstanvar","text":"... List mixtures convert. verbose Enables printing mixture priors chains start sample. Defaults FALSE.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mixture distributions as brms priors — mixstanvar","text":"stanvars object used argument stanvars argument brm model.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Mixture distributions as brms priors — mixstanvar","text":"declare mixture priors brm model requires two steps: First, mixture densities need converted adapter function mixstanvar stanvars object passed stanvars argument brm function. extends Stan code data generated brm mixture densities can used priors within brm model. second step assign parameters brm model mixture density prior using set_prior command brms. adapter function translates mixture distributions defined R respective mixture distribution Stan. Within Stan mixture distributions named accordance R functions used create respective mixture distributions. , mixture density normals created mixnorm referred mixnorm_lpdf Stan one can refer density mixnorm within set_prior functions (suffix _lpdf automatically added brm). arguments mixture distributions depend specific distribution type follows: arguments mixture densities refer different density parameters automatically extracted mixtures converted. Important argument names must used declare mixture prior. mixture convert part ... argument mixstanvar label determined using name given list. case name given, name R object used. declare prior parameter mixture distribution must used arguments following convention label_argument. Please refer examples section illustration. Note: Models created brm use default data-dependent centering covariates leading shift overall intercept. commonly desirable applications functionality. therefore strongly recommended pass option center=FALSE argument brms formula created bf function demonstrated example .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mixture distributions as brms priors — mixstanvar","text":"","code":"if (FALSE) { # \\dontrun{ # The mixstanvar adapter requires the optional packages brms and glue stopifnot(require(\"brms\"), require(\"glue\")) # Assume we prefer a logistic regression MCMC analysis rather than a # beta-binomial analysis for the responder endpoint of the ankylosing # spondylitis (AS) example. Reasons to prefer a regression analysis is # to allow for baseline covariate adjustments, for example. map_AS_beta <- mixbeta(c(0.62, 19.2, 57.8), c(0.38, 3.5, 9.4)) # First we need to convert the beta mixture to a respective mixture on # the log odds scale and approximate it with a normal mixture density. map_AS_samp <- rmix(map_AS_beta, 1E4) map_AS <- mixfit(logit(map_AS_samp), type = \"norm\", Nc = 2) # Trial results for placebo and secukinumab. trial <- data.frame( n = c(6, 24), r = c(1, 15), arm = factor(c(\"placebo\", \"secukinumab\")) ) # Define brms model such that the overall intercept corresponds to the # placebo response rate on the logit scale. NOTE: The use of # center=FALSE is required here as detailed in the note above. model <- bf(r | trials(n) ~ 1 + arm, family = binomial, center = FALSE) # to obtain detailed information on the declared model parameters use # get_prior(model, data=trial) # declare model prior with reference to mixture normal map prior... model_prior <- prior(mixnorm(map_w, map_m, map_s), coef = Intercept) + prior(normal(0, 2), class = b) # ... which must be made available to brms using the mixstanvar adapter. # Note that the map_AS prior is labeled \"map\" as referred to in the # previous prior declaration. analysis <- brm(model, data = trial, prior = model_prior, stanvars = mixstanvar(map = map_AS), seed = 365634, refresh = 0 ) # Let's compare the logistic regression estimate for the probability # of a positive treatment effect (secukinumab response rate exceeding # the response rate of placebo) to the direct beta-binomial analysis: hypothesis(analysis, \"armsecukinumab > 0\") post_secukinumab <- postmix(mixbeta(c(1, 0.5, 1)), r = 15, n = 24) post_placebo <- postmix(map_AS_beta, r = 1, n = 6) pmixdiff(post_secukinumab, post_placebo, 0, lower.tail = FALSE) # The posterior probability for a positive treatment effect # is very close to unity in both cases. } # }"},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":null,"dir":"Reference","previous_headings":"","what":"Operating Characteristics for 1 Sample Design — oc1S","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"oc1S function defines 1 sample design (prior, sample size, decision function) calculation frequency decision evaluated 1 conditional assuming known parameters. function returned performs actual operating characteristics calculations.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"","code":"oc1S(prior, n, decision, ...) # S3 method for class 'betaMix' oc1S(prior, n, decision, ...) # S3 method for class 'normMix' oc1S(prior, n, decision, sigma, eps = 1e-06, ...) # S3 method for class 'gammaMix' oc1S(prior, n, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"prior Prior analysis. n Sample size experiment. decision One-sample decision function use; see decision1S. ... Optional arguments. sigma fixed reference scale. left unspecified, default reference scale prior assumed. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"Returns function one argument theta calculates frequency decision function evaluated 1 defined 1 sample design. Note returned function takes vectors arguments.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"oc1S function defines 1 sample design returns function calculates operating characteristics. frequency decision function evaluated 1 assumption given true distribution data defined known parameter \\(\\theta\\). 1 sample design defined prior, sample size decision function, \\(D(y)\\). uniquely define decision boundary, see decision1S_boundary. calling oc1S function, internally critical value \\(y_c\\) (using decision1S_boundary) calculated function returns can used calculated desired frequency evaluated $$ F(y_c|\\theta). $$","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"oc1S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. oc1S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture prior mean. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function oc1S extra argument eps (defaults \\(10^{-6}\\)). critical value \\(y_c\\) searched region probability mass 1-eps \\(y\\). oc1S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function oc1S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"","code":"# non-inferiority example using normal approximation of log-hazard # ratio, see ?decision1S for all details s <- 2 flat_prior <- mixnorm(c(1, 0, 100), sigma = s) nL <- 233 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) theta_c <- theta_ni - za * s / sqrt(n1) # standard NI design decA <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # double criterion design # statistical significance (like NI design) dec1 <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # require mean to be at least as good as theta_c dec2 <- decision1S(0.5, theta_c, lower.tail = TRUE) # combination decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) theta_eval <- c(theta_a, theta_c, theta_ni) # evaluate different designs at two sample sizes designA_n1 <- oc1S(flat_prior, n1, decA) #> Using default prior reference scale 2 designA_nL <- oc1S(flat_prior, nL, decA) #> Using default prior reference scale 2 designC_n1 <- oc1S(flat_prior, n1, decComb) #> Using default prior reference scale 2 designC_nL <- oc1S(flat_prior, nL, decComb) #> Using default prior reference scale 2 # evaluate designs at the key log-HR of positive treatment (HR<1), # the indecision point and the NI margin designA_n1(theta_eval) #> [1] 0.80084529 0.49980774 0.04995032 designA_nL(theta_eval) #> [1] 0.92039728 0.64489439 0.04997268 designC_n1(theta_eval) #> [1] 0.80084529 0.49980774 0.04995032 designC_nL(theta_eval) #> [1] 0.84991646 0.49995959 0.02185859 # to understand further the dual criterion design it is useful to # evaluate the criterions separatley: # statistical significance criterion to warrant NI... designC1_nL <- oc1S(flat_prior, nL, dec1) #> Using default prior reference scale 2 # ... or the clinically determined indifference point designC2_nL <- oc1S(flat_prior, nL, dec2) #> Using default prior reference scale 2 designC1_nL(theta_eval) #> [1] 0.92039728 0.64489439 0.04997268 designC2_nL(theta_eval) #> [1] 0.84991646 0.49995959 0.02185859 # see also ?decision1S_boundary to see which of the two criterions # will drive the decision"},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":null,"dir":"Reference","previous_headings":"","what":"Operating Characteristics for 2 Sample Design — oc2S","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"oc2S function defines 2 sample design (priors, sample sizes & decision function) calculation operating characeristics. function returned calculates calculates frequency decision function evaluated 1 assuming known parameters.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"","code":"oc2S(prior1, prior2, n1, n2, decision, ...) # S3 method for class 'betaMix' oc2S(prior1, prior2, n1, n2, decision, eps, ...) # S3 method for class 'normMix' oc2S( prior1, prior2, n1, n2, decision, sigma1, sigma2, eps = 1e-06, Ngrid = 10, ... ) # S3 method for class 'gammaMix' oc2S(prior1, prior2, n1, n2, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"prior1 Prior sample 1. prior2 Prior sample 2. n1, n2 Sample size respective samples. Sample size n1 must greater 0 sample size n2 must greater equal 0. decision Two-sample decision function use; see decision2S. ... Optional arguments. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\). sigma1 fixed reference scale sample 1. left unspecified, default reference scale prior 1 assumed. sigma2 fixed reference scale sample 2. left unspecified, default reference scale prior 2 assumed. Ngrid Determines density discretization grid decision function evaluated (see details).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"Returns function called two arguments theta1 theta2 return frequencies decision function evaluated 1 whenever data distributed according known parameter values sample. Note returned function takes vector arguments.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"oc2S function defines 2 sample design returns function calculates operating characteristics. frequency decision function evaluated 1 assumption given true distribution data defined known parameter \\(\\theta_1\\) \\(\\theta_2\\). 2 sample design defined priors, sample sizes decision function, \\(D(y_1,y_2)\\). uniquely define decision boundary , see decision2S_boundary. Calling oc2S function calculates decision boundary \\(D_1(y_2)\\) (see decision2S_boundary) returns function can used calculate desired frequency evaluated $$ \\int f_2(y_2|\\theta_2) F_1(D_1(y_2)|\\theta_1) dy_2. $$ See examples specifics supported mixture priors.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"oc2S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. optional argument eps defined, approximate method used limits search decision boundary region 1-eps probability mass. useful designs large sample sizes exact approach costly calculate. oc2S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture priors means. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function two extra arguments (defaults): eps (\\(10^{-6}\\)) Ngrid (10). decision boundary searched region probability mass 1-eps, respectively \\(y_1\\) \\(y_2\\). continuous decision function evaluated discrete grid, determined spacing \\(\\delta_2 = \\sigma_2/\\sqrt{N_{grid}}\\). decision boundary evaluated discrete steps, spline used inter-polate decision boundary intermediate points. oc2S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function oc2S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y_1\\) \\(y_2\\), respectively.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"","code":"# example from Schmidli et al., 2014 dec <- decision2S(0.975, 0, lower.tail = FALSE) prior_inf <- mixbeta(c(1, 4, 16)) prior_rob <- robustify(prior_inf, weight = 0.2, mean = 0.5) prior_uni <- mixbeta(c(1, 1, 1)) N <- 40 N_ctl <- N - 20 # compare designs with different priors design_uni <- oc2S(prior_uni, prior_uni, N, N_ctl, dec) design_inf <- oc2S(prior_uni, prior_inf, N, N_ctl, dec) design_rob <- oc2S(prior_uni, prior_rob, N, N_ctl, dec) # type I error curve(design_inf(x, x), 0, 1) curve(design_uni(x, x), lty = 2, add = TRUE) curve(design_rob(x, x), lty = 3, add = TRUE) # power curve(design_inf(0.2 + x, 0.2), 0, 0.5) curve(design_uni(0.2 + x, 0.2), lty = 2, add = TRUE) curve(design_rob(0.2 + x, 0.2), lty = 3, add = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":null,"dir":"Reference","previous_headings":"","what":"Diagnostic plots for EM fits — plot.EM","title":"Diagnostic plots for EM fits — plot.EM","text":"Produce diagnostic plots EM fits returned mixfit.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Diagnostic plots for EM fits — plot.EM","text":"","code":"# S3 method for class 'EM' plot(x, size = 1.25, link = c(\"identity\", \"logit\", \"log\"), ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Diagnostic plots for EM fits — plot.EM","text":"x EM fit size Optional argument passed ggplot2 routines control line thickness. link Choice applied link function. Can take one values identity (default), logit log. ... Ignored. Overlays fitted mixture density histogram density plot raw sample fitted. Applying link function can beneficial, example logit (log) link beta (gamma) mixtures obtained Binomial (Poisson) gMAP analysis.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Diagnostic plots for EM fits — plot.EM","text":"list ggplot plots diagnostics EM run. Detailed EM diagnostic plots included global option RBesT.verbose set TRUE. include plots parameters component vs iteration. plot mixture density histogram density fitted sample always returned.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Diagnostic plots for EM fits — plot.EM","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Diagnostic plots for EM fits — plot.EM","text":"","code":"bmix <- mixbeta(rob = c(0.2, 1, 1), inf = c(0.8, 10, 2)) bsamp <- rmix(bmix, 1000) bfit <- mixfit(bsamp, type = \"beta\", Nc = 2) pl <- plot(bfit) print(pl$mixdens) print(pl$mix) # \\donttest{ # a number of additional plots are generated in verbose mode .user_option <- options(RBesT.verbose = TRUE) pl_all <- plot(bfit) # recover previous user options options(.user_option) names(pl_all) #> [1] \"mixdist\" \"w\" \"a\" \"b\" \"lN\" \"Lm\" \"N\" #> [8] \"m\" \"Lw\" \"lli\" \"mixdens\" \"mixecdf\" \"mix\" # [1] \"mixdist\" \"a\" \"b\" \"w\" \"m\" \"N\" \"Lm\" \"lN\" \"Lw\" \"lli\" \"mixdens\" \"mixecdf\" \"mix\" # }"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":null,"dir":"Reference","previous_headings":"","what":"Diagnostic plots for gMAP analyses — plot.gMAP","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"Diagnostic plots gMAP analyses","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"","code":"# S3 method for class 'gMAP' plot(x, size = NULL, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"x gMAP object size Controls line sizes traceplots forest plot. ... Ignored.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"function returns list ggplot objects.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"Creates MCMC diagnostics forest plot (including model estimates) gMAP analysis. customized forest plot, please use dedicated function forest_plot.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":null,"dir":"Reference","previous_headings":"","what":"Probability of Success for a 1 Sample Design — pos1S","title":"Probability of Success for a 1 Sample Design — pos1S","text":"pos1S function defines 1 sample design (prior, sample size, decision function) calculation frequency decision evaluated 1 assuming distribution parameter. function returned performs actual operating characteristics calculations.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Probability of Success for a 1 Sample Design — pos1S","text":"","code":"pos1S(prior, n, decision, ...) # S3 method for class 'betaMix' pos1S(prior, n, decision, ...) # S3 method for class 'normMix' pos1S(prior, n, decision, sigma, eps = 1e-06, ...) # S3 method for class 'gammaMix' pos1S(prior, n, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Probability of Success for a 1 Sample Design — pos1S","text":"prior Prior analysis. n Sample size experiment. decision One-sample decision function use; see decision1S. ... Optional arguments. sigma fixed reference scale. left unspecified, default reference scale prior assumed. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Probability of Success for a 1 Sample Design — pos1S","text":"Returns function takes single argument mix, mixture distribution control parameter. Calling function mixture distribution calculates PoS.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Probability of Success for a 1 Sample Design — pos1S","text":"pos1S function defines 1 sample design returns function calculates probability success. probability success frequency decision function evaluated 1 assumption given true distribution data implied distirbution parameter \\(\\theta\\). Calling pos1S function calculates critical value \\(y_c\\) returns function can used evaluate PoS different predictive distributions evaluated $$ \\int F(y_c|\\theta) p(\\theta) d\\theta, $$ \\(F\\) distribution function sampling distribution \\(p(\\theta)\\) specifies assumed true distribution parameter \\(\\theta\\). distribution \\(p(\\theta)\\) mixture distribution given mix argument function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Probability of Success for a 1 Sample Design — pos1S","text":"pos1S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. pos1S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture prior mean. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function pos1S extra argument eps (defaults \\(10^{-6}\\)). critical value \\(y_c\\) searched region probability mass 1-eps \\(y\\). pos1S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function pos1S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Probability of Success for a 1 Sample Design — pos1S","text":"","code":"# non-inferiority example using normal approximation of log-hazard # ratio, see ?decision1S for all details s <- 2 flat_prior <- mixnorm(c(1, 0, 100), sigma = s) nL <- 233 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) theta_c <- theta_ni - za * s / sqrt(n1) # assume we would like to conduct at an interim analysis # of PoS after having observed 20 events with a HR of 0.8. # We first need the posterior at the interim ... post_ia <- postmix(flat_prior, m = log(0.8), n = 20) #> Using default prior reference scale 2 # dual criterion decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) # ... and we would like to know the PoS for a successful # trial at the end when observing 10 more events pos_ia <- pos1S(post_ia, 10, decComb) #> Using default prior reference scale 2 # our knowledge at the interim is just the posterior at # interim such that the PoS is pos_ia(post_ia) #> [1] 0.534741"},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":null,"dir":"Reference","previous_headings":"","what":"Probability of Success for 2 Sample Design — pos2S","title":"Probability of Success for 2 Sample Design — pos2S","text":"pos2S function defines 2 sample design (priors, sample sizes & decision function) calculation probability success. function returned calculates calculates frequency decision function evaluated 1 parameters distributed according given distributions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Probability of Success for 2 Sample Design — pos2S","text":"","code":"pos2S(prior1, prior2, n1, n2, decision, ...) # S3 method for class 'betaMix' pos2S(prior1, prior2, n1, n2, decision, eps, ...) # S3 method for class 'normMix' pos2S( prior1, prior2, n1, n2, decision, sigma1, sigma2, eps = 1e-06, Ngrid = 10, ... ) # S3 method for class 'gammaMix' pos2S(prior1, prior2, n1, n2, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Probability of Success for 2 Sample Design — pos2S","text":"prior1 Prior sample 1. prior2 Prior sample 2. n1, n2 Sample size respective samples. Sample size n1 must greater 0 sample size n2 must greater equal 0. decision Two-sample decision function use; see decision2S. ... Optional arguments. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\). sigma1 fixed reference scale sample 1. left unspecified, default reference scale prior 1 assumed. sigma2 fixed reference scale sample 2. left unspecified, default reference scale prior 2 assumed. Ngrid Determines density discretization grid decision function evaluated (see details).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Probability of Success for 2 Sample Design — pos2S","text":"Returns function called two arguments mix1 mix2 return frequencies decision function evaluated 1. argument expected mixture distribution representing assumed true distribution parameter group.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Probability of Success for 2 Sample Design — pos2S","text":"pos2S function defines 2 sample design returns function calculates probability success. probability success frequency decision function evaluated 1 assumption given true distribution data implied distirbution parameters \\(\\theta_1\\) \\(\\theta_2\\). calculation analogous operating characeristics oc2S difference instead assuming known (point-wise) true parameter values distribution specified parameter. Calling pos2S function calculates decision boundary \\(D_1(y_2)\\) returns function can used evaluate PoS different predictive distributions. evaluated $$ \\int\\int\\int f_2(y_2|\\theta_2) \\, p(\\theta_2) \\, F_1(D_1(y_2)|\\theta_1) \\, p(\\theta_1) \\, dy_2 d\\theta_2 d\\theta_1. $$ \\(F\\) distribution function sampling distribution \\(p(\\theta_1)\\) \\(p(\\theta_2)\\) specifies assumed true distribution parameters \\(\\theta_1\\) \\(\\theta_2\\), respectively. distribution \\(p(\\theta_1)\\) \\(p(\\theta_2)\\) mixture distribution given mix1 mix2 argument function. example, binary case integration predictive distribution, BetaBinomial, instead binomial distribution performed data space wherever decision function evaluated 1. aspects calculation 2-sample operating characteristics, see oc2S.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Probability of Success for 2 Sample Design — pos2S","text":"pos2S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. optional argument eps defined, approximate method used limits search decision boundary region 1-eps probability mass. useful designs large sample sizes exact approach costly calculate. pos2S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture priors means. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function two extra arguments (defaults): eps (\\(10^{-6}\\)) Ngrid (10). decision boundary searched region probability mass 1-eps, respectively \\(y_1\\) \\(y_2\\). continuous decision function evaluated discrete grid, determined spacing \\(\\delta_2 = \\sigma_2/\\sqrt{N_{grid}}\\). decision boundary evaluated discrete steps, spline used inter-polate decision boundary intermediate points. pos2S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function pos2S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y_1\\) \\(y_2\\), respectively.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Probability of Success for 2 Sample Design — pos2S","text":"","code":"# see ?decision2S for details of example priorT <- mixnorm(c(1, 0, 0.001), sigma = 88, param = \"mn\") priorP <- mixnorm(c(1, -49, 20), sigma = 88, param = \"mn\") # the success criteria is for delta which are larger than some # threshold value which is why we set lower.tail=FALSE successCrit <- decision2S(c(0.95, 0.5), c(0, 50), FALSE) # example interim outcome postP_interim <- postmix(priorP, n = 10, m = -50) #> Using default prior reference scale 88 postT_interim <- postmix(priorT, n = 20, m = -80) #> Using default prior reference scale 88 # assume that mean -50 / -80 were observed at the interim for # placebo control(n=10) / active treatment(n=20) which gives # the posteriors postP_interim #> Univariate normal mixture #> Reference scale: 88 #> Mixture Components: #> comp1 #> w 1.00000 #> m -49.33333 #> s 16.06653 postT_interim #> Univariate normal mixture #> Reference scale: 88 #> Mixture Components: #> comp1 #> w 1.00000 #> m -79.99600 #> s 19.67691 # then the PoS to succeed after another 20/30 patients is pos_final <- pos2S(postP_interim, postT_interim, 20, 30, successCrit) #> Using default prior 1 reference scale 88 #> Using default prior 2 reference scale 88 pos_final(postP_interim, postT_interim) #> [1] 0.145567"},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":null,"dir":"Reference","previous_headings":"","what":"Conjugate Posterior Analysis — postmix","title":"Conjugate Posterior Analysis — postmix","text":"Calculates posterior distribution data data given prior priormix, prior mixture conjugate distributions. posterior also mixture conjugate distributions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conjugate Posterior Analysis — postmix","text":"","code":"postmix(priormix, data, ...) # S3 method for class 'betaMix' postmix(priormix, data, n, r, ...) # S3 method for class 'normMix' postmix(priormix, data, n, m, se, ...) # S3 method for class 'gammaMix' postmix(priormix, data, n, m, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conjugate Posterior Analysis — postmix","text":"priormix prior (mixture conjugate distributions). data individual data. individual data given, summary data provided (see ). ... includes arguments depend specific case, see description . n sample size. r Number successes. m Sample mean. se Sample standard error.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Conjugate Posterior Analysis — postmix","text":"conjugate prior-likelihood pair convenient property posterior distributional class prior. property also applies mixtures conjugate priors. Let $$p(\\theta;\\mathbf{w},\\mathbf{},\\mathbf{b})$$ denote conjugate mixture prior density data $$y|\\theta \\sim f(y|\\theta),$$ \\(f(y|\\theta)\\) likelihood. posterior mixture component \\(k\\) equal respective posterior \\(k\\)th prior component updated weights \\(w'_k\\), $$p(\\theta;\\mathbf{w'},\\mathbf{'},\\mathbf{b'}|y) = \\sum_{k=1}^K w'_k \\, p_k(\\theta;'_k,b'_k|y).$$ weight \\(w'_k\\) \\(k\\)th component determined marginal likelihood new data \\(y\\) \\(k\\)th prior distribution given predictive distribution \\(k\\)th component, $$w'_k \\propto w_k \\, \\int p_k(\\theta;a_k,b_k) \\, f(y|\\theta) \\, d\\theta \\equiv w^\\ast_k .$$ final weight \\(w'_k\\) given appropriate normalization, \\(w'_k = w^\\ast_k / \\sum_{k=1}^K w^\\ast_k\\). words, weight component \\(k\\) proportional likelihood data \\(y\\) generated respective component, .e. marginal probability; details, see example Schmidli et al., 2015. Note: prior weights \\(w_k\\) fixed, posterior weights \\(w'_k \\neq w_k\\) still change due changing normalization. data \\(y\\) can either given individual data summary data (sufficient statistics). See details implemented conjugate mixture prior densities.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Conjugate Posterior Analysis — postmix","text":"postmix(betaMix): Calculates posterior beta mixture distribution. individual data vector expected vector 0 1, .e. series Bernoulli experiments. Alternatively, sufficient statistics n r can given, .e. number trials successes, respectively. postmix(normMix): Calculates posterior normal mixture distribution sampling likelihood normal fixed standard deviation. Either individual data vector data can given sufficient statistics standard error se sample mean m. sample size n used instead sample standard error, reference scale prior used calculate standard error. standard error se sample size n given, reference scale prior updated; however recommended use command sigma set reference standard deviation. postmix(gammaMix): Calculates posterior gamma mixture distribution Poisson exponential likelihoods. Poisson case supported version.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Conjugate Posterior Analysis — postmix","text":"Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conjugate Posterior Analysis — postmix","text":"","code":"# binary example with individual data (1=event,0=no event), uniform prior prior.unif <- mixbeta(c(1, 1, 1)) data.indiv <- c(1, 0, 1, 1, 0, 1) posterior.indiv <- postmix(prior.unif, data.indiv) print(posterior.indiv) #> Univariate beta mixture #> Mixture Components: #> comp1 #> w 1 #> a 5 #> b 3 # or with summary data (number of events and number of patients) r <- sum(data.indiv) n <- length(data.indiv) posterior.sum <- postmix(prior.unif, n = n, r = r) print(posterior.sum) #> Univariate beta mixture #> Mixture Components: #> comp1 #> w 1 #> a 5 #> b 3 # binary example with robust informative prior and conflicting data prior.rob <- mixbeta(c(0.5, 4, 10), c(0.5, 1, 1)) posterior.rob <- postmix(prior.rob, n = 20, r = 18) print(posterior.rob) #> Univariate beta mixture #> Mixture Components: #> comp1 comp2 #> w 0.002672948 0.997327052 #> a 22.000000000 19.000000000 #> b 12.000000000 3.000000000 # normal example with individual data sigma <- 88 prior.mean <- -49 prior.se <- sigma / sqrt(20) prior <- mixnorm(c(1, prior.mean, prior.se), sigma = sigma) data.indiv <- c(-46, -227, 41, -65, -103, -22, 7, -169, -69, 90) posterior.indiv <- postmix(prior, data.indiv) # or with summary data (mean and number of patients) mn <- mean(data.indiv) n <- length(data.indiv) posterior.sum <- postmix(prior, m = mn, n = n) #> Using default prior reference scale 88 print(posterior.sum) #> Univariate normal mixture #> Reference scale: 88 #> Mixture Components: #> comp1 #> w 1.00000 #> m -51.43333 #> s 16.06653"},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":null,"dir":"Reference","previous_headings":"","what":"Predictive Distributions for Mixture Distributions — preddist","title":"Predictive Distributions for Mixture Distributions — preddist","text":"Predictive distribution mixture conjugate distributions (beta, normal, gamma).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predictive Distributions for Mixture Distributions — preddist","text":"","code":"preddist(mix, ...) # S3 method for class 'betaMix' preddist(mix, n = 1, ...) # S3 method for class 'normMix' preddist(mix, n = 1, sigma, ...) # S3 method for class 'gammaMix' preddist(mix, n = 1, ...) # S3 method for class 'mvnormMix' preddist(mix, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predictive Distributions for Mixture Distributions — preddist","text":"mix mixture distribution ... includes arguments depend specific prior-likelihood pair, see description . n predictive sample size, set default 1 sigma fixed reference scale normal mixture. left unspecified, default reference scale mixture assumed.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predictive Distributions for Mixture Distributions — preddist","text":"function returns normal, beta gamma mixture matching predictive distribution \\(y_n\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predictive Distributions for Mixture Distributions — preddist","text":"Given mixture density (either posterior prior) $$p(\\theta,\\mathbf{w},\\mathbf{},\\mathbf{b})$$ data likelihood $$y|\\theta \\sim f(y|\\theta),$$ predictive distribution one-dimensional summary \\(y_n\\) $n$ future observations distributed $$y_n \\sim \\int p(\\theta,\\mathbf{w},\\mathbf{},\\mathbf{b}) \\, f(y_n|\\theta) \\, d\\theta .$$ distribution marginal distribution data mixture density. binary Poisson data \\(y_n = \\sum_{=1}^n y_i\\) sum future events. normal data, mean\\(\\bar{y}_n = 1/n \\sum_{=1}^n y_i\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Predictive Distributions for Mixture Distributions — preddist","text":"preddist(betaMix): Obtain matching predictive distribution beta distribution, BetaBinomial. preddist(normMix): Obtain matching predictive distribution Normal constant standard deviation. Note reference scale returned Normal mixture meaningless individual components updated appropriatley. preddist(gammaMix): Obtain matching predictive distribution Gamma. Poisson likelihoods supported. preddist(mvnormMix): Multivariate normal mixtures predictive densities (yet) supported.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predictive Distributions for Mixture Distributions — preddist","text":"","code":"# Example 1: predictive distribution from uniform prior. bm <- mixbeta(c(1, 1, 1)) bmPred <- preddist(bm, n = 10) # predictive proabilities and cumulative predictive probabilities x <- 0:10 d <- dmix(bmPred, x) names(d) <- x barplot(d) cd <- pmix(bmPred, x) names(cd) <- x barplot(cd) # median mdn <- qmix(bmPred, 0.5) mdn #> [1] 5 # Example 2: 2-comp Beta mixture bm <- mixbeta(inf = c(0.8, 15, 50), rob = c(0.2, 1, 1)) plot(bm) bmPred <- preddist(bm, n = 10) plot(bmPred) mdn <- qmix(bmPred, 0.5) mdn #> [1] 2 d <- dmix(bmPred, x = 0:10) # \\donttest{ n.sim <- 100000 r <- rmix(bmPred, n.sim) d #> [1] 0.08814590 0.19605661 0.23899190 0.19379686 0.11696528 0.05913205 #> [7] 0.03082078 0.02104347 0.01863583 0.01822732 0.01818400 table(r) / n.sim #> r #> 0 1 2 3 4 5 6 7 8 9 #> 0.08968 0.19746 0.23763 0.19322 0.11681 0.05847 0.03068 0.02091 0.01858 0.01803 #> 10 #> 0.01853 # } # Example 3: 3-comp Normal mixture m3 <- mixnorm(c(0.50, -0.2, 0.1), c(0.25, 0, 0.2), c(0.25, 0, 0.5), sigma = 10) print(m3) #> Univariate normal mixture #> Reference scale: 10 #> Mixture Components: #> comp1 comp2 comp3 #> w 0.50 0.25 0.25 #> m -0.20 0.00 0.00 #> s 0.10 0.20 0.50 summary(m3) #> mean sd 2.5% 50.0% 97.5% #> -0.1000000 0.2958040 -0.6426984 -0.1490997 0.6426789 plot(m3) predm3 <- preddist(m3, n = 2) #> Using default mixture reference scale 10 plot(predm3) print(predm3) #> Univariate normal mixture #> Reference scale: 10 #> Mixture Components: #> comp1 comp2 comp3 #> w 0.500000 0.250000 0.250000 #> m -0.200000 0.000000 0.000000 #> s 7.071775 7.073896 7.088723 summary(predm3) #> mean sd 2.5% 50.0% 97.5% #> -0.1000000 7.0772523 -13.9709762 -0.1000673 13.7713589"},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":null,"dir":"Reference","previous_headings":"","what":"Predictions from gMAP analyses — predict.gMAP","title":"Predictions from gMAP analyses — predict.gMAP","text":"Produces sample predictive distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predictions from gMAP analyses — predict.gMAP","text":"","code":"# S3 method for class 'gMAP' predict( object, newdata, type = c(\"response\", \"link\"), probs = c(0.025, 0.5, 0.975), na.action = na.pass, thin, ... ) # S3 method for class 'gMAPpred' print(x, digits = 3, ...) # S3 method for class 'gMAPpred' summary(object, ...) # S3 method for class 'gMAPpred' as.matrix(x, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predictions from gMAP analyses — predict.gMAP","text":"newdata data.frame must contain columns input gMAP analysis. left , posterior prediction fitted data entries gMAP object performed (shrinkage estimates). type sets reported scale (response (default) link). probs defines quantiles reported. na.action handle missings. thin thinning applied derived gMAP object. ... ignored. x, object gMAP analysis object predictions performed digits number displayed significant digits.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predictions from gMAP analyses — predict.gMAP","text":"Predictions made using \\(\\tau\\) prediction stratum gMAP object. details syntax, please refer predict.glm example .","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predictions from gMAP analyses — predict.gMAP","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) # create a fake data set with a covariate trans_cov <- transform(transplant, country = cut(1:11, c(0, 5, 8, Inf), c(\"CH\", \"US\", \"DE\"))) set.seed(34246) map <- gMAP(cbind(r, n - r) ~ 1 + country | study, data = trans_cov, tau.dist = \"HalfNormal\", tau.prior = 1, # Note on priors: we make the overall intercept weakly-informative # and the regression coefficients must have tighter sd as these are # deviations in the default contrast parametrization beta.prior = rbind(c(0, 2), c(0, 1), c(0, 1)), family = binomial, ## ensure fast example runtime thin = 1, chains = 1 ) #> Warning: The largest R-hat is 1.07, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. # posterior predictive distribution for each input data item (shrinkage estimates) pred_cov <- predict(map) pred_cov #> Meta-Analytic-Predictive Prior Predictions #> Scale: response #> #> Summary: #> mean sd 2.5% 50% 97.5% #> 1 0.205 0.0510 0.123 0.199 0.291 #> 2 0.195 0.0406 0.120 0.195 0.263 #> 3 0.216 0.0412 0.154 0.209 0.302 #> 4 0.253 0.0427 0.193 0.250 0.333 #> 5 0.197 0.0276 0.154 0.198 0.252 #> 6 0.184 0.0458 0.103 0.181 0.273 #> 7 0.238 0.0516 0.149 0.233 0.344 #> 8 0.168 0.0317 0.120 0.166 0.239 #> 9 0.241 0.0521 0.154 0.239 0.345 #> 10 0.174 0.0313 0.121 0.171 0.246 #> 11 0.243 0.0231 0.206 0.246 0.279 # extract sample as matrix samp <- as.matrix(pred_cov) # predictive distribution for each input data item (if the input studies were new ones) pred_cov_pred <- predict(map, trans_cov) pred_cov_pred #> Meta-Analytic-Predictive Prior Predictions #> Scale: response #> #> Summary: #> mean sd 2.5% 50% 97.5% #> 1 0.210 0.0650 0.0979 0.198 0.323 #> 2 0.221 0.0749 0.1210 0.220 0.379 #> 3 0.220 0.0748 0.1130 0.212 0.418 #> 4 0.214 0.0720 0.1110 0.206 0.377 #> 5 0.203 0.0697 0.0791 0.196 0.348 #> 6 0.198 0.0747 0.1030 0.180 0.360 #> 7 0.203 0.0638 0.1070 0.200 0.333 #> 8 0.191 0.0617 0.0827 0.188 0.299 #> 9 0.237 0.0985 0.0998 0.217 0.446 #> 10 0.238 0.0885 0.1200 0.234 0.406 #> 11 0.234 0.0792 0.0838 0.232 0.418 # a summary function returns the results as matrix summary(pred_cov) #> mean sd 2.5% 50% 97.5% #> 1 0.2046888 0.05103156 0.1233163 0.1989446 0.2908793 #> 2 0.1950595 0.04060381 0.1204606 0.1949910 0.2630753 #> 3 0.2160028 0.04120147 0.1538030 0.2089321 0.3022593 #> 4 0.2529856 0.04270467 0.1929258 0.2503303 0.3333643 #> 5 0.1969653 0.02764795 0.1544012 0.1980138 0.2518814 #> 6 0.1843000 0.04581607 0.1028620 0.1814753 0.2733072 #> 7 0.2383059 0.05162711 0.1487544 0.2326939 0.3438535 #> 8 0.1680299 0.03170941 0.1198606 0.1659361 0.2389757 #> 9 0.2410675 0.05211712 0.1538566 0.2392947 0.3450478 #> 10 0.1742228 0.03131481 0.1213062 0.1707167 0.2455262 #> 11 0.2426294 0.02309088 0.2061749 0.2463644 0.2792656 # obtain a prediction for new data with specific covariates pred_new <- predict(map, data.frame(country = \"CH\", study = 12)) pred_new #> Meta-Analytic-Predictive Prior Predictions #> Scale: response #> #> Summary: #> mean sd 2.5% 50% 97.5% #> 1 0.217 0.0793 0.0926 0.209 0.404 ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":null,"dir":"Reference","previous_headings":"","what":"Robustify Mixture Priors — robustify","title":"Robustify Mixture Priors — robustify","text":"Add non-informative component mixture prior.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Robustify Mixture Priors — robustify","text":"","code":"robustify(priormix, weight, mean, n = 1, ...) # S3 method for class 'betaMix' robustify(priormix, weight, mean, n = 1, ...) # S3 method for class 'gammaMix' robustify(priormix, weight, mean, n = 1, ...) # S3 method for class 'normMix' robustify(priormix, weight, mean, n = 1, ..., sigma)"},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Robustify Mixture Priors — robustify","text":"priormix orior (mixture conjugate distributions). weight weight given non-informative component (0 < weight < 1). mean mean non-informative component. recommended set parameter explicitly. n number observations non-informative prior corresponds , defaults 1. ... optional arguments ignored. sigma Sampling standard deviation case Normal mixtures.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Robustify Mixture Priors — robustify","text":"New mixture extra non-informative component named robust.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Robustify Mixture Priors — robustify","text":"recommended robustify informative priors derived gMAP using unit-information priors . protects prior-data conflict, see example Schmidli et al., 2015. procedure can used beta, gamma normal mixture priors. unit-information prior (see Kass Wasserman, 1995) corresponds prior represents observation n=1 null hypothesis. null problem dependent strongly recommend make use mean argument accordingly. See definition default mean. weights mixture priors rescaled (1-weight) non-informative prior assigned weight given.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Robustify Mixture Priors — robustify","text":"robustify(betaMix): default mean set 1/2 represents difference occurrence rates one two outcomes. uniform Beta(1,1) appropriate practical applications, RBesT uses n+1 sample size default robust prior uniform instead Beta(1/2,1/2) strictly defined unit information prior case. robustify(gammaMix): default mean set mean prior mixture. strongly recommended explicitly set mean location null hypothesis. robustify(normMix): default mean set mean prior mixture. strongly recommended explicitly set mean location null hypothesis, often equal 0. also recommended explicitly set sampling standard deviation using sigma argument.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Robustify Mixture Priors — robustify","text":"Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032. Kass RE, Wasserman L Reference Bayesian Test Nested Hypotheses Relationship Schwarz Criterion J Amer Statist Assoc 1995; 90(431):928-934.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Robustify Mixture Priors — robustify","text":"","code":"bmix <- mixbeta(inf1 = c(0.2, 8, 3), inf2 = c(0.8, 10, 2)) plot(bmix) rbmix <- robustify(bmix, weight = 0.1, mean = 0.5) rbmix #> Univariate beta mixture #> Mixture Components: #> inf1 inf2 robust #> w 0.18 0.72 0.10 #> a 8.00 10.00 1.00 #> b 3.00 2.00 1.00 plot(rbmix) gmnMix <- mixgamma(inf1 = c(0.2, 2, 3), inf2 = c(0.8, 2, 5), param = \"mn\") plot(gmnMix) rgmnMix <- robustify(gmnMix, weight = 0.1, mean = 2) rgmnMix #> Univariate Gamma mixture #> Mixture Components: #> inf1 inf2 robust #> w 0.18 0.72 0.10 #> a 6.00 10.00 2.00 #> b 3.00 5.00 1.00 plot(rgmnMix) nm <- mixnorm(inf1 = c(0.2, 0.5, 0.7), inf2 = c(0.8, 2, 1), sigma = 2) plot(nm) rnMix <- robustify(nm, weight = 0.1, mean = 0, sigma = 2) rnMix #> Univariate normal mixture #> Reference scale: 2 #> Mixture Components: #> inf1 inf2 robust #> w 0.18 0.72 0.10 #> m 0.50 2.00 0.00 #> s 0.70 1.00 2.00 plot(rnMix)"},{"path":"https://opensource.nibr.com/RBesT/reference/support.html","id":null,"dir":"Reference","previous_headings":"","what":"Support of Distributions — support","title":"Support of Distributions — support","text":"Returns support distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/support.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Support of Distributions — support","text":"","code":"support(mix)"},{"path":"https://opensource.nibr.com/RBesT/reference/support.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Support of Distributions — support","text":"mix Mixture distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":null,"dir":"Reference","previous_headings":"","what":"Transplant. — transplant","title":"Transplant. — transplant","text":"Data set containing historical information standard treatment phase IV trial de novo transplant patients. primary outcome treament failure (binary).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transplant. — transplant","text":"","code":"transplant"},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Transplant. — transplant","text":"data frame 4 rows 3 variables: study study n study size r number events","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Transplant. — transplant","text":"Neuenschwander B, Capkun-Niggli G, Branson M, Spiegelhalter DJ. Summarizing historical information controls clinical trials. Clin Trials. 2010; 7(1):5-18","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/uniroot_int.html","id":null,"dir":"Reference","previous_headings":"","what":"Find root of univariate function of integers — uniroot_int","title":"Find root of univariate function of integers — uniroot_int","text":"Uses bisectioning algorithm search give interval change sign returns integer closest 0.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/uniroot_int.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Find root of univariate function of integers — uniroot_int","text":"","code":"uniroot_int( f, interval, ..., f.lower = f(interval[1], ...), f.upper = f(interval[2], ...), maxIter = 1000 )"},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-8-1","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.8-1 - January 20th, 2025","text":"Fixed issue ess function beta gamma mixtures used inside lapply sapply.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-18-0---january-8th-2025","dir":"Changelog","previous_headings":"","what":"RBesT 1.8-0 - January 8th, 2025","title":"RBesT 1.8-0 - January 8th, 2025","text":"CRAN release: 2025-01-08","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-8-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.8-0 - January 8th, 2025","text":"Enable ESS calculation normal mixture densities used context standard one-parameter exponential family new family argument. example, can used calculate ESS normal mixture density representing logit transformed response scale. Reformat R sources using styler.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-8-0","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.8-0 - January 8th, 2025","text":"Correct boundary behavior BinaryExactCI function whenever responses non-responses observed. Fixes issue #21. Stabilize internal beta mixture information function, corrects unstable ESS ELIR computations. Addresses issue #22.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-4---november-21st-2024","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-4 - November 21st, 2024","title":"RBesT 1.7-4 - November 21st, 2024","text":"CRAN release: 2024-11-21","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-4 - November 21st, 2024","text":"Added mixstanvar automatic generation distribution functions allowing truncated priors brms mixtures Slight speed increase Stan model efficient construction likelihood. Also reducing object size gMAP objects avoiding store redundant variables. Upgraded testthat edition version 3.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-4","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-4 - November 21st, 2024","text":"Fix issue #18 ESS ELIR aborting whenever one mixture component zero weight. Fixed rare issue estimating ESS ELIR beta mixtures. calculation aborted due boundary issues now avoided. Avoid underflow beta-binomial distribution. Replace calls deprecated ggplot2::qplot respective calls ggplot2::ggplot. Use new array notation mixstanvar generated Stan code make generated Stan programs compatible Stan >= 2.33","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-3---january-2nd-2024","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-3 - January 2nd, 2024","title":"RBesT 1.7-3 - January 2nd, 2024","text":"CRAN release: 2024-01-08","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-3 - January 2nd, 2024","text":"Updated Stan model file syntax use new array syntax required Stan >=2.33. upgrades minimal Stan version 2.26. Moved vignettes articles decrease size R packages. Articles available package homepage.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-3","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-3 - January 2nd, 2024","text":"Added pngquant system requirements package requested CRAN.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-2---august-21st-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-2 - August 21st, 2023","title":"RBesT 1.7-2 - August 21st, 2023","text":"CRAN release: 2023-08-21","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-2 - August 21st, 2023","text":"Add unit tests mixstanvar function disabled integration tests CI/CD systems require significant resources due need compile Stan models. unit tests ensure things correct RBesT side things. Use new scheme roxygen2 document package documentation.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-2","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-2 - August 21st, 2023","text":"Make EM normal multivariate normal mixtures deterministic resulting density depend random seed longer, intended behavior. Note change may cause estimated normal / MVN mixtures numerically different compared previous version. estimated density (statistically) still .","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-1---august-8th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-1 - August 8th, 2023","title":"RBesT 1.7-1 - August 8th, 2023","text":"CRAN release: 2023-08-10","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-1","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-1 - August 8th, 2023","text":"Allow use mixture priors brms models new adapter function mixstanvar. Allow use named dimensions multivariate normal mixtures. Add experimental diagnostic plots mixture multivariate normal EM fits. subject changes future release user feedback welcome. Compress png plots vignettes saving ~40% file size package sources.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-1","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-1 - August 8th, 2023","text":"Fix issue plotting EM diagnostic debugging plots normal mixtures. Comply newer ggplot2 standards use aes_string.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-0---july-19th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-0 - July 19th, 2023","title":"RBesT 1.7-0 - July 19th, 2023","text":"CRAN release: 2023-07-20","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-0 - July 19th, 2023","text":"Implementation multivariate normal mixture support first version. includes density evaluation, basic summary functions multivariate normal EM fitting. Support yet complete densites, expanded upcoming releases. Change default option constrain_gt1 EM beta mixtures TRUE. default constrain fitted parameters beta mixture component greater unity required finite ESS elir calculations.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-7---june-26th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-7 - June 26th, 2023","title":"RBesT 1.6-7 - June 26th, 2023","text":"CRAN release: 2023-06-29","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-7","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-7 - June 26th, 2023","text":"resolve compilation source issues platforms triggered changes rstantools correct documentation difference distribution improve PoS co-data vignette","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-6---march-3rd-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-6 - March 3rd, 2023","title":"RBesT 1.6-6 - March 3rd, 2023","text":"CRAN release: 2023-03-03","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-6","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-6 - March 3rd, 2023","text":"ensure C++17 compatiblity per CRAN (triggers issue clang 16) fix links README.md now link new public pkgdown web-site","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-5---february-8th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-5 - February 8th, 2023","title":"RBesT 1.6-5 - February 8th, 2023","text":"CRAN release: 2023-02-10","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-6-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.6-5 - February 8th, 2023","text":"upon package load RBesT now report date release respective git commit hash used create sources package.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-5","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-5 - February 8th, 2023","text":"ensure predict new studies sample study specifc random effect per iteration . important MAP priors covariate effects (pooled studies).","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-4---august-5th-2022","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-4 - August 5th, 2022","title":"RBesT 1.6-4 - August 5th, 2022","text":"CRAN release: 2022-08-08","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-6-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.6-4 - August 5th, 2022","text":"use clustermq inplace batchtools SBC runs. Also use L’Ecuyer CMG random number gen SBC runs. expand introductory vignette plot ESS vs robust weight start using matrixStats speed EM algorithms & OCs avoid warning whenever 2S normal design expanded domain called repeatedly add mixdist plot plotting mixture resulting *mixfit call add warning message printing gMAP analysis Stan sampler issues due divergent transitions non-convergence indicated large Rhat","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-4","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-4 - August 5th, 2022","text":"mixture density evaluations (dmix) defined link function evaluate correctly, visible plotting mixtures (one component) link functions","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-3---november-23rd-2021","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-3 - November 23rd, 2021","title":"RBesT 1.6-3 - November 23rd, 2021","text":"CRAN release: 2021-11-24 update references JSS publication","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-2---september-3rd-2021","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-2 - September 3rd, 2021","title":"RBesT 1.6-2 - September 3rd, 2021","text":"CRAN release: 2021-09-03 link RcppParallel align new Stan requirements address CRAN comments","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-1---may-28th-2020","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-1 - May 28th, 2020","title":"RBesT 1.6-1 - May 28th, 2020","text":"CRAN release: 2020-05-28 stabilize elir ESS integration integrating per mixture component comply forthcoming stricter stanc3 Stan transpiler address warnings ggplot2 3.3.0","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-0---march-27th-2020","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-0 - March 27th, 2020","title":"RBesT 1.6-0 - March 27th, 2020","text":"CRAN release: 2020-03-28 fix CI system issues fix issues normal decision2S_boundary boundaries grown add demo 2S OC simulation code time--event endpoint constant hazard assumption drop tidyverse dependency expand SBC checks include group specifc estimates stop setting ggplot2 default theme loading package. plots now use bayesplot theme can modified bayesplot_theme_* functions. See ?bayesplot::bayesplot_theme_get. correct transformation issue MAP variances vignette - thanks Ping Chen allow constrained fitting beta mixtures & b parameters greater 1. new default behavior function inform . informational message removed future release. introduced new mixecdf plot diagnostic EM fits","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-4---october-22nd-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-4 - October 22nd, 2019","title":"RBesT 1.5-4 - October 22nd, 2019","text":"CRAN release: 2019-10-23 Now really fix n2=0 case 2S design functions indirect comparisons Update package structure new rstantools 2.0 system","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-3---august-28th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-3 - August 28th, 2019","title":"RBesT 1.5-3 - August 28th, 2019","text":"CRAN release: 2019-08-28 Fix vignette MAP variances (missing definition)","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-2---august-28th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-2 - August 28th, 2019","title":"RBesT 1.5-2 - August 28th, 2019","text":"Speedup example run time Avoid use cat functions use message instead Replace dontrun examples donttest Require NOT_CRAN=true tests run","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-1---august-28th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-1 - August 28th, 2019","title":"RBesT 1.5-1 - August 28th, 2019","text":"Work around compiler warning clang fedora platform","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-0---august-15th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-0 - August 15th, 2019","title":"RBesT 1.5-0 - August 15th, 2019","text":"Fix indirect comparisons work normal/Poisson/binomial (inexact) allow n2=0 oc2S calls. Make mixture quantile function robust work flat mixture priors. Align ESS Morita calculations Neuenschwander B. et al., pre-print 2019; arXiv:1907.04185","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-14-0---july-27th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.4-0 - July 27th, 2019","title":"RBesT 1.4-0 - July 27th, 2019","text":"CRAN release: 2019-06-27 Introduce elir ESS method new default ESS Allow sample prior predictive gMAP (argument prior_PD) Switch internally ab parametrized version EM beta algorithm","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-8---april-3nd-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-8 - April 3nd, 2019","title":"RBesT 1.3-8 - April 3nd, 2019","text":"CRAN release: 2019-04-04 Use Simulation Based Calibration gMAP model qualification Improve covariate handling (naming data items) Speedup Stan model avoiding matrix-vector products many zeros Fix index issue differential discounting used covariates Make initialization EM algorithms robust Avoid special build hacks MacOS","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-7---november-16th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-7 - November 16th, 2018","title":"RBesT 1.3-7 - November 16th, 2018","text":"CRAN release: 2018-11-19 Address issue build process MacOS.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-6---november-14th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-6 - November 14th, 2018","title":"RBesT 1.3-6 - November 14th, 2018","text":"CRAN release: 2018-11-15 Re-create vignettes proper MCMC sampling. Automate R package build process using CI/CD.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-5---november-13th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-5 - November 13th, 2018","title":"RBesT 1.3-5 - November 13th, 2018","text":"CRAN release: 2018-11-14 Corrected 1.3-4 release notes include MAP variances vignette Make build process robust (updated src/Makevars{.win}) Added probability success interim vignette Added probability success co-data vignette","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-4---october-16th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-4 - October 16th, 2018","title":"RBesT 1.3-4 - October 16th, 2018","text":"CRAN release: 2018-10-17 Make package work rstan 2.18.1. Revert BetaBinomial implementation back R functions. Bugfix decision1S_boundary normal case extreme parameter configurations (fixes pos1S & oc1S well). Bugfix mixcombine plot normal mixtures without sigma defined. Bugfix repeated calls decision2S_boundary normal endpoint (fixes pos2S & oc2S well). Avoid use deprecated bayesplot function arguments whenever divergencies occured. (corrected) Added MAP variances vignette","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-3---february-2nd-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-3 - February 2nd, 2018","title":"RBesT 1.3-3 - February 2nd, 2018","text":"CRAN release: 2018-02-02 Change numerical equality testing use expect_equal (uses .equal internally accounting machine specifc tolerances) pass tests long double case. Numerical tolerances reverted back 1.3-1 settings.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-2---january-25th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-2 - January 25th, 2018","title":"RBesT 1.3-2 - January 25th, 2018","text":"CRAN release: 2018-01-25 Adjust numerical tolerances pass tests long double case","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-1---december-21st-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-1 - December 21st, 2017","title":"RBesT 1.3-1 - December 21st, 2017","text":"CRAN release: 2017-12-21 Add Trustees Columbia copyright respective files DESCRIPTION","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-0---december-21st-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-0 - December 21st, 2017","title":"RBesT 1.3-0 - December 21st, 2017","text":"Added probability success calculation 1+2 sample case. Added decision1+2S_boundary functions (deprecated use y2 argument oc functions) Added RBesT.integrate_args option greater control density integrations. Correct cumulative predictive beta mixtures return 0/1 --range values (instead leaving ). Deprecated functions oc1+2Sdecision replaced decision1+2S.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-3---august-21st-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-3 - August 21st, 2017","title":"RBesT 1.2-3 - August 21st, 2017","text":"CRAN release: 2017-08-21 Fix plotting procedures work bayesplot 1.3.0","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-2---july-12th-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-2 - July 12th, 2017","title":"RBesT 1.2-2 - July 12th, 2017","text":"CRAN release: 2017-07-12 speedup example runtimes.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-1---july-12th-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-1 - July 12th, 2017","title":"RBesT 1.2-1 - July 12th, 2017","text":"Compactify reference PDF manual. Introduce sampling arguments gMAP. Shorten runtime examples.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-0---july-3rd-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-0 - July 3rd, 2017","title":"RBesT 1.2-0 - July 3rd, 2017","text":"First CRAN release. Update documentation.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-11-0---may-15th-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.1-0 - May 15th, 2017","title":"RBesT 1.1-0 - May 15th, 2017","text":"Redesign reference scale handling normal case. Enable standard error sufficient statistic function. Introduced plotting options. Increased adapt_delta default set stepsize+max_treedepth default. Added RBesT.MC.{ncp, init, rescale} option. Corrections Poisson OC. pmixdiff function now integrates full support. Added argument enables designs based log-odds decisions relative risks. New graphical vignette new forest plot function. Use standard plotting package.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-10-0---march-10th-2016","dir":"Changelog","previous_headings":"","what":"RBesT 1.0-0 - March 10th, 2016","title":"RBesT 1.0-0 - March 10th, 2016","text":"Stabilize integration pmixdiff beta mixtures logit transform. Set default adapt_delta 0.975. Made RBesT compatible ggplot2 2.0. Allowed n2=0 function.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-09-2---oct-28th-2015","dir":"Changelog","previous_headings":"","what":"RBesT 0.9-2 - Oct 28th 2015","title":"RBesT 0.9-2 - Oct 28th 2015","text":"Corrected Poisson stratified estimates. Added warning divergent transitions. Added crohn dataset.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-09-1---sept-3rd-2015","dir":"Changelog","previous_headings":"","what":"RBesT 0.9-1 - Sept 3rd 2015","title":"RBesT 0.9-1 - Sept 3rd 2015","text":"Minor typo fixes.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-09-0---sept-1st-2015","dir":"Changelog","previous_headings":"","what":"RBesT 0.9-0 - Sept 1st 2015","title":"RBesT 0.9-0 - Sept 1st 2015","text":"First release.","code":""}]
+[{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Probability of Success with Co-Data","text":"co-data concept introduced [1]. differs use historical data approach makes use contemporary data. meta-analytic-predictive (MAP) analysis assumes historical data known time-point specyfing analysis retrospective summary available data. MAP prior combined current trial data. co-data approach extends sequential procedure meta-analytic-combined (MAC) analysis. MAC approach available data analyzed single step - , historical concurrent data combined single inference step. approaches MAP MAC yield exactly results demonstrated appendix bottom. example co-data scenario drug development simultaneous execution twin phase III trails registriation. setting, futility analysis interim analysis may take historical contemporary data account co-data approach. example discussed [1] using probability success (PoS) metric assess futility interim analysis discussed detail. key property probability success metric consideration uncertainty parameters conditional available data. contrast, conditional power (CP) calculates frequency given experemintal design successful known value parameters. example, 1-sample experiment one-sided success criterion trial successful collected data yNy_N sample size NN exceeds critical value ycy_c; recall critical value ycy_c determined success criterion, prior sample size evaluated. Assuming sampling model data p(y|θ)p(y|\\theta), CPN(θ)=∫(yN>yc)p(yN|θ)dyN. CP_N(\\theta) = \\int (y_N > y_c) \\, p(y_N|\\theta) \\, dy_N. integration data yNy_N comprises possible outcomes trial. Note start trial, CPN(θ0)CP_N(\\theta_0) type error rate conventional null hypothesis (θ=θ0\\theta=\\theta_0) CPN(θa)CP_N(\\theta_a) power trial alternative (θ=θa\\theta=\\theta_a). interim analysis sample size nIn_I, conditional power evaluated conditional observed data far (nIn_I measurements) remaining sample size (N−nIN-n_I) random distributed according p(y|θ)p(y|\\theta) θ\\theta set known value, CPN−nI(θ|ynI)=∫(ynI+yN−nI=yN>yc|ynI)p(yN−nI|θ)dyN−nI. CP_{N-n_I}(\\theta|y_{n_I}) = \\int (y_{n_I} + y_{N-n_I} = y_N > y_c|y_{n_I}) \\, p(y_{N-n_I}|\\theta) \\, dy_{N-n_I}. known value can set equal observed point estimate interim, CPN−nI(θ̂|ynI)CP_{N-n_I}(\\hat{\\theta}_{}|y_{n_I}), assumed true alternative, CPN−nI(θa|ynI)CP_{N-n_I}(\\theta_a|y_{n_I}), used plan trial. probability success contrast assigns θ\\theta distribution marginalizes conditional power distribution. absence additional trial external information distribution posterior p(θ|ynI)p(\\theta|y_{n_I}) obtained prior p(θ)p(\\theta) data collected interim, PoSI=∫CPN−nI(θ|ynI)p(θ|ynI)dθ. PoS_I = \\int CP_{N-n_I}(\\theta|y_{n_I}) \\, p(\\theta|y_{n_I}) \\, d\\theta. However, knowledge θ\\theta can refined data-sources like completed (historical) concurrent trials available, PoSI,H,...=∫CPN−nI(θ|ynI)p(θ|yI,yH,...)dθ. PoS_{,H,...} = \\int CP_{N-n_I}(\\theta|y_{n_I}) \\, p(\\theta|y_{},y_{H},...) \\, d\\theta. important note conditional power always evaluated respect trial data (prior) . Thus, additional data-sources part analysis trial. practice means probability success usually calculated trial uses non-informative priors, interim may use additional data-sources refine knowledge θ\\theta part trial analysis.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"example-data-scenario","dir":"Articles","previous_headings":"","what":"Example Data Scenario","title":"Probability of Success with Co-Data","text":"following hypothetical example [1] discussed. assumed endpoint time--event, analyzed using normal approximation log-rank statistic comparing two groups. 1:1 randomization standard error log-hazard ratio scales number events 2/Nevents2/\\sqrt{N_{events}}. implies corresponding sampling standard deviation 22, defines unit information prior used later analysis. historical data considered proof concept phase II trial. twin phase III studies event driven. trial stops whenever total 379379 events reached interim planned whenever least 150150 events occured. assumed true hazard ratio used design trial 0.80.8. Example data: remaining outline vignette first evaluate design properties trials, calculate probability success interim trial (using trial data). Next, probability success calculated using addition historical data. Subsequently, probability success trial calculated also using historical data concurrent phase III data trial B. Finally, overall probability success calculated, defined joint success trials. appendix equivalence MAP MAC approach demonstrated.","code":"trials <- data.frame( study = c(\"PoC\", \"PhII\", \"PhIII_A\", \"PhIII_B\"), deaths = c(8, 85, 162, 150), HR = c(0.7, 0.75, 0.83, 0.78), stringsAsFactors = FALSE ) ## under the normal approximation of the log-HR, the sampling sd is 2 ## such that the standard errors are sqrt(4/events) trials <- trials %>% mutate(logHR = log(HR), sem = sqrt(4 / deaths)) kable(trials, digits = 2)"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"statistical-trial-design-considerations","dir":"Articles","previous_headings":"","what":"Statistical Trial Design Considerations","title":"Probability of Success with Co-Data","text":"Key design choices: time--event endpoint phase III trials stop target # events 379 null hypothesis difference HR, θ0=1.0\\theta_0 = 1.0 one-sided α=0.025\\alpha = 0.025 alternative hypothesis assumes true HR θa=0.75\\theta_a=0.75 interim least 150 events reached Historical data: promising internal PoC promising phase II Co-data: two phase III trials run parallel ⇒\\Rightarrow phase III trial concurrent Define design choices","code":"Nev <- 379 alt_HR <- 0.75 alt_logHR <- log(alt_HR) alpha <- 0.025"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"power-calculation","dir":"Articles","previous_headings":"Statistical Trial Design Considerations","what":"Power calculation","title":"Probability of Success with Co-Data","text":"use unit information prior non-informative prior define using mean & effective sample size (ESS) specification: Define conditional power overall trial: alternative design choices result 80% power impact unit-information prior minimal can seen comparing frequentist calculation: RBesT can explore conditional power range alternatives:","code":"unit_inf <- mixnorm(c(1, 0, 1), sigma = 2, param = \"mn\") unit_inf ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 ## w 1 ## m 0 ## s 2 success_crit <- decision1S(1 - alpha, 0) ## let's print the defined criterion success_crit ## 1 sample decision function ## Conditions for acceptance: ## P(theta <= 0) > 0.975 design <- oc1S(unit_inf, Nev, success_crit, sigma = 2) design(alt_logHR) ## [1] 0.7986379 power.t.test(n = Nev, delta = -1 * alt_logHR, sd = 2, type = \"one.sample\", sig.level = 0.025, alternative = \"one.sided\") ## ## One-sample t test power calculation ## ## n = 379 ## delta = 0.2876821 ## sd = 2 ## sig.level = 0.025 ## power = 0.7976343 ## alternative = one.sided ggplot(data.frame(HR = c(0.5, 1.2)), aes(HR)) + stat_function(fun = compose(design, log)) + vline_at(c(alt_HR, 1.0), linetype = I(2)) + scale_y_continuous(breaks = seq(0, 1, by = 0.1)) + scale_x_continuous(breaks = c(alt_HR, seq(0, 1.2, by = 0.2))) + ylab(NULL) + xlab(expression(theta[a])) + ggtitle(paste(\"Power for N =\", Nev, \"events\"))"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"critical-value","dir":"Articles","previous_headings":"Statistical Trial Design Considerations","what":"Critical value","title":"Probability of Success with Co-Data","text":"critical value determines observed logHR just conclude success criterion fulfilled. can check : Ok, observing critical value, get success. Now, observe 1% worse result? success ⇒\\Rightarrow critical boundary value.","code":"design_crit <- decision1S_boundary(unit_inf, Nev, success_crit, sigma = 2) design_crit ## [1] -0.2017185 exp(design_crit) ## [1] 0.8173249 success_crit(postmix(unit_inf, m = design_crit, n = 379)) ## Using default prior reference scale 2 ## [1] 1 success_crit(postmix(unit_inf, m = design_crit + log(1.01), n = 379)) ## Using default prior reference scale 2 ## [1] 0"},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"no-use-of-historical-information","dir":"Articles","previous_headings":"PoS at interim for phase III trial A only","what":"No use of historical information","title":"Probability of Success with Co-Data","text":"Posterior treatment effect interim. trial uses non-informative prior treatment effect: Now interested PoS trial completion. prior use analysis second half given data collected far. returned function can now calculate PoS assuming distribution treatment effect. case use historical information, just interim posterior: command integrates conditional power uncertainty treatment effect defined PoSIPoS_I. conditional power operating characteristics trial coincide whenever condition observed data. key difference conditional power compared probability success assumes known value parameter interest. can seen follows: First define conditional power conditional observed data, CPN−nI(θ|ynI)CP_{N-n_I}(\\theta|y_{n_I}): conditional power assuming alternative true (HR 0.75): case uncertainty treatment effect (se=10−4se=10^-4), result agrees probability success calculation: trial B calculation :","code":"interim_A <- postmix(unit_inf, m = trials$logHR[3], se = trials$sem[3]) interim_A ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 ## w 1.0000000 ## m -0.1851865 ## s 0.1566521 interim_pos_A <- pos1S(interim_A, Nev - trials$deaths[3], success_crit, sigma = 2) interim_pos_A(interim_A) ## [1] 0.4465623 interim_oc_A <- oc1S(interim_A, Nev - trials$deaths[3], success_crit, sigma = 2) interim_oc_A(alt_logHR) ## [1] 0.708769 interim_pos_A(mixnorm(c(1, alt_logHR, 1E-4))) ## [1] 0.7087689 interim_B <- postmix(unit_inf, m = trials$logHR[4], se = trials$sem[4]) interim_pos_B <- pos1S(interim_B, Nev - trials$deaths[4], success_crit, sigma = 2) interim_pos_B(interim_B) ## [1] 0.6411569"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"use-of-historical-information---map-approach","dir":"Articles","previous_headings":"PoS at interim for phase III trial A only","what":"Use of historical information - MAP approach","title":"Probability of Success with Co-Data","text":"However, historical information can take advantage interim better informed decision. data phase III trials includes PoC phase II trial. now derive MAP prior; recall MAP prior prediction log-hazard ratio future trial: interim even knowledge available treatment effect interim data can include MAP prior: PoS posterior interim (representing historical interim data collected) : Note redefined interim_pos_A, calculates PoS phase III trial taking account final analysis use non-informative prior. trial B calculation :","code":"base <- trials[1:2, ] set.seed(342345) base_map_mc <- gMAP(cbind(logHR, sem) ~ 1 | study, family = gaussian, data = base, weights = deaths, tau.dist = \"HalfNormal\", tau.prior = 0.5, beta.prior = cbind(0, 2) ) forest_plot(base_map_mc, est = \"MAP\") base_map <- automixfit(base_map_mc) plot(base_map)$mix + xlab(expression(log(theta))) base_map ## EM for Normal Mixture Model ## Log-Likelihood = -3110.728 ## ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 comp2 comp3 ## w 0.6094510 0.2591800 0.1313691 ## m -0.2943573 -0.2783962 -0.3331379 ## s 0.2990546 0.6500315 1.1889177 interim_A_combined <- postmix(base_map, m = trials$logHR[3], se = trials$sem[3]) interim_pos_A(interim_A_combined) ## [1] 0.4850564 interim_B_combined <- postmix(base_map, m = trials$logHR[4], se = trials$sem[4]) interim_pos_B(interim_B_combined) ## [1] 0.6686476"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"use-of-historical-information---mac-approach","dir":"Articles","previous_headings":"PoS at interim for phase III trial A only","what":"Use of historical information - MAC approach","title":"Probability of Success with Co-Data","text":"However, even information can used , since phase III result trial B also available: Now trial B specific posterior interim can extract : obtain posterior (restrict first 4 columns) turn MCMC posterior sample parametric mixture finally evaluate PoS aligns published result assumption full exchangeability. trial B computations :","code":"interim_map_mc <- update(base_map_mc, data = trials) kable(fitted(interim_map_mc), digits = 3) interim_map_post <- as.matrix(interim_map_mc)[, 1:4] dim(interim_map_post) # posterior is given as matrix: iteration x parameter ## [1] 4000 4 head(interim_map_post, n = 3) ## parameters ## iterations theta[1] theta[2] theta[3] theta[4] ## [1,] 0.5793535 -0.4054789 0.1303989 -0.30952085 ## [2,] -0.3457577 -0.3818282 -0.3105840 -0.32644175 ## [3,] -0.1232030 -0.1211176 -0.1414171 -0.08166256 interim_A_allcombined <- automixfit(interim_map_post[, \"theta[3]\"]) interim_pos_A(interim_A_allcombined) ## [1] 0.5030811 interim_B_allcombined <- automixfit(interim_map_post[, \"theta[4]\"]) interim_pos_B(interim_B_allcombined) ## [1] 0.6415822"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"differential-discounting","dir":"Articles","previous_headings":"","what":"Differential discounting","title":"Probability of Success with Co-Data","text":"Differential discounting allows weight different data-sources differently. example, may assume greater heterogeneity historical data comparison twin phase III trials. Assign data historical (2) concurrent data strata (1):","code":"trials <- trials %>% mutate(stratum = c(2, 2, 1, 1)) kable(trials, digits = 2) set.seed(435345) interim_diff_map_mc <- gMAP(cbind(logHR, sem) ~ 1 | study, tau.strata = stratum, family = gaussian, data = trials, weights = deaths, tau.dist = \"HalfNormal\", tau.prior = c(0.5, 1), beta.prior = cbind(0, 2) ) interim_diff_map_post <- as.matrix(interim_diff_map_mc)[, 1:4] interim_A_diff_allcombined <- automixfit(interim_diff_map_post[, \"theta[3]\"]) interim_B_diff_allcombined <- automixfit(interim_diff_map_post[, \"theta[4]\"]) interim_pos_A(interim_A_diff_allcombined) ## [1] 0.493427 interim_pos_B(interim_B_diff_allcombined) ## [1] 0.6394128"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"pos-for-both-phase-iii-trials-being-successful","dir":"Articles","previous_headings":"","what":"PoS for both phase III trials being successful","title":"Probability of Success with Co-Data","text":"far calculated individual PoS per trial, interesting overall PoS trials successful. Recall, PoS conditional power integrated assumed true effect distribution. Hence, trial : explained, conditional power operating characerstic design conditioning already observed data: PoS integral conditional power parameter space θ\\theta representing knowledge. integral can evaluated Monte-Carlo (MC) approach PoSI=∫CPN−nI(θ|ynI)p(θ|ynI)dθ≈1S∑=1SCP(θi), PoS_I = \\int CP_{N-n_I}(\\theta|y_{n_I}) \\, p(\\theta|y_{n_I}) \\, d\\theta \\approx \\frac{1}{S} \\sum_{=1}^S CP(\\theta_i), whenever sample p(θ|ynI)p(\\theta|y_{n_I}) size SS… : MC approach calculating PoS. now considering probability trials successful perform MC integration joint density p(θA,θB|ynIA,ynIB)p(\\theta_A,\\theta_B|y_{n_{I_A}},y_{n_{I_B}}) PoS=∬CPN−nIA(θA|ynIA)CPN−nIB(θB|ynIB)p(θA,θB|ynIA,ynIB)dθAdθB≈1S∑=1SCPN−nIA(θA,|ynIA)CPN−nIB(θB,|ynIB). \\begin{aligned} PoS &= \\iint CP_{N-n_{I_A}}(\\theta_A|y_{n_{I_A}}) \\, CP_{N-n_{I_B}}(\\theta_B|y_{n_{I_B}})\\, p(\\theta_A,\\theta_B|y_{n_{I_A}},y_{n_{I_B}}) \\, d\\theta_A d\\theta_B \\\\ & \\approx \\frac{1}{S} \\sum_{=1}^S CP_{N-n_{I_A}}(\\theta_{,}|y_{n_{I_A}}) \\, CP_{N-n_{I_B}}(\\theta_{B,}|y_{n_{I_B}}). \\end{aligned} Thus need also get conditional power trial B interim… …integrate posterior samples (differential discounting case) slightly larger assuming independence: due dependence posteriors full exchangeability case ","code":"interim_pos_A(interim_A) ## [1] 0.4465623 interim_oc_A <- oc1S(interim_A, Nev - trials$deaths[3], success_crit, sigma = 2) interim_A_samp <- rmix(interim_A, 1E4) mean(interim_oc_A(interim_A_samp)) ## [1] 0.4479449 interim_oc_B <- oc1S(interim_B, Nev - trials$deaths[4], success_crit, sigma = 2) mean(interim_oc_A(interim_diff_map_post[, \"theta[3]\"]) * interim_oc_B(interim_diff_map_post[, \"theta[4]\"])) ## [1] 0.3452887 interim_pos_A(interim_A) * interim_pos_B(interim_B) ## [1] 0.2863165 cor(interim_diff_map_post[, c(\"theta[3]\", \"theta[4]\")]) ## theta[3] theta[4] ## theta[3] 1.0000000 0.3187079 ## theta[4] 0.3187079 1.0000000 mean(interim_oc_A(interim_map_post[, \"theta[3]\"]) * interim_oc_B(interim_map_post[, \"theta[4]\"])) ## [1] 0.3521087"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"summary","dir":"Articles","previous_headings":"","what":"Summary","title":"Probability of Success with Co-Data","text":"now calculated increasing complexity probability success various data constellations. new trials conducted whenever previous trial results positive, important take note potential selection bias. Moreover, adding historical data sources situation likely increase probability success illustrated summary preceding calculations. Phase III trial : Phase III trial B:","code":"## only interim data of trial A interim_pos_A(interim_A) ## [1] 0.4465623 ## in addition with prior historical data PoC & phase II data interim_pos_A(interim_A_combined) ## [1] 0.4850564 ## finally with the interim data of the phase III B interim_pos_A(interim_A_allcombined) ## [1] 0.5030811 ## only interim data of trial B interim_pos_B(interim_B) ## [1] 0.6411569 ## in addition with prior historical data PoC & phase II data interim_pos_B(interim_B_combined) ## [1] 0.6686476 ## finally with the interim data of the phase III A interim_pos_B(interim_B_allcombined) ## [1] 0.6415822"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"appendix-map-and-mac-equivalence","dir":"Articles","previous_headings":"","what":"Appendix: MAP and MAC equivalence","title":"Probability of Success with Co-Data","text":"preceeding sections used MAP MAC equivalence already. proof equivalence presented reference [2]. formal deriavtion shown end section MAP MAC provide exact results, difference sequential vs joint analysis (see also [2]): MAP: Summarize historical information MAP update MAP trial result (MCMC, postmix). MAC: Directly summarize historical information trial result single step (MCMC data). two results using MAP MAC line . reason MAP approach used historical data phase III trial interim data . contrast, MAC approach used historical data interim phase III data trials. show equivalence need align mismatch used data. Run gMAP base data produce large MCMC sample (10 chains) get high precision. Force accurate fit 5 components: Now, combine MAP prior (representing historical knowledge) interim data trial : Run respective MAC analysis (thus need historical data + phase III trial, excluding phase III B data): turn MCMC posterior sample parametric mixture Now let’s overlay two posterior’s PoS essentially ","code":"base_map_mc_2 <- gMAP(cbind(logHR, sem) ~ 1 | study, family = gaussian, data = base, weights = deaths, tau.dist = \"HalfNormal\", tau.prior = 0.5, beta.prior = cbind(0, 2), chains = ifelse(is_CRAN, 2, 20) ) base_map_2 <- mixfit(base_map_mc_2, Nc = 5) base_map_2 ## EM for Normal Mixture Model ## Log-Likelihood = -15088.42 ## ## Univariate normal mixture ## Reference scale: 2 ## Mixture Components: ## comp1 comp2 comp3 comp4 comp5 ## w 0.40929935 0.20586574 0.18866513 0.12833707 0.06783271 ## m -0.28173830 -0.64782890 0.06087094 0.16129924 -1.05921673 ## s 0.22707579 0.32358363 0.33140706 0.86765455 0.73553054 interim_A_combined_2 <- postmix(base_map_2, m = trials$logHR[3], se = trials$sem[3]) interim_map_mc_2 <- update(base_map_mc_2, data = trials[-4, ]) ## Warning: There were 3 divergent transitions after warmup. See ## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup ## to find out why this is a problem and how to eliminate them. ## Warning: Examine the pairs() plot to diagnose sampling problems ## Warning in gMAP(formula = cbind(logHR, sem) ~ 1 | study, family = gaussian, : In total 3 divergent transitions occured during the sampling phase. ## Please consider increasing adapt_delta closer to 1 with the following command prior to gMAP: ## options(RBesT.MC.control=list(adapt_delta=0.999)) interim_map_post_2 <- as.matrix(interim_map_mc_2)[, 1:3] interim_A_allcombined_2 <- mixfit(interim_map_post_2[, \"theta[3]\"], Nc = 5) interim_A_allcombined_2 ## EM for Normal Mixture Model ## Log-Likelihood = 10763.73 ## ## Univariate normal mixture ## Mixture Components: ## comp1 comp2 comp3 comp4 comp5 ## w 0.22608509 0.22287087 0.22104424 0.19134605 0.13865375 ## m -0.22358073 -0.31478209 -0.11546035 -0.32415990 -0.01378153 ## s 0.05767847 0.12976158 0.06117267 0.07871764 0.09025686 ggplot(data.frame(logHR = c(-0.8, 0.25)), aes(logHR)) + stat_function(fun = dmix, args = list(mix = interim_A_combined_2), aes(linetype = \"MAP\")) + stat_function(fun = dmix, args = list(mix = interim_A_allcombined_2), aes(linetype = \"MAC\")) + scale_linetype_discrete(\"Analysis\") + ggtitle(\"Posterior log hazard of phase III A trial at interim\") interim_pos_A(interim_A_combined_2) ## [1] 0.489214 interim_pos_A(interim_A_allcombined_2) ## [1] 0.4943454"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"formal-map-and-mac-equivalence","dir":"Articles","previous_headings":"Appendix: MAP and MAC equivalence","what":"Formal MAP and MAC equivalence","title":"Probability of Success with Co-Data","text":"stated equivalence requires posterior trial specific parameter p(θ⋆|y⋆,yH),p(\\theta_\\star|y_\\star,y_H), conditional trial specific data y⋆y_\\starand historical data yHy_H (MAC approach, joint use yH,y⋆y_H,y_\\star), equivalent obtaining MAP prior p(θ⋆|yH)p(\\theta_\\star|y_H) based historical data analyzing new trial prior. p(θ⋆|y⋆,yH)∝p(θ⋆,θH|y⋆,yH)∝p(y⋆,yH|θ⋆,θH)p(θ⋆,θH)=p(y⋆|θ⋆)p(yH|θH)p(θ⋆,θH)∝p(y⋆|θ⋆)p(θ⋆,θH|yH)∝p(y⋆|θ⋆)p(θ⋆|yH) \\begin{aligned} p(\\theta_\\star|y_\\star,y_H) &\\propto p(\\theta_\\star,\\theta_H|y_\\star,y_H) \\\\ &\\propto p(y_\\star,y_H|\\theta_\\star,\\theta_H) \\, p(\\theta_\\star,\\theta_H) \\\\ &= p(y_\\star|\\theta_\\star) \\, p(y_H|\\theta_H) \\, p(\\theta_\\star,\\theta_H) \\\\ &\\propto p(y_\\star|\\theta_\\star) \\, p(\\theta_\\star,\\theta_H|y_H) \\\\ &\\propto p(y_\\star|\\theta_\\star) \\, p(\\theta_\\star|y_H) \\end{aligned} equivalence holds use meta-analytic model.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Probability of Success with Co-Data","text":"[1] Neuenschwander, B., Roychoudhury, S., & Schmidli, H. (2016). Use Co-Data Clinical Trials. Statistics Biopharmaceutical Research, 8(3), 345-354. [2] 1. Schmidli H, Gsteiger S, Roychoudhury S, O’Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics. 2014;70(4):1023-1032.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_codata.html","id":"r-session-info","dir":"Articles","previous_headings":"","what":"R Session Info","title":"Probability of Success with Co-Data","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] purrr_1.0.2 dplyr_1.1.4 bayesplot_1.11.1 ggplot2_3.5.1 ## [5] knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 rlang_1.1.5 ## [25] munsell_0.5.1 withr_3.0.2 cachem_1.1.0 ## [28] yaml_2.3.10 StanHeaders_2.32.10 parallel_4.4.2 ## [31] tools_4.4.2 rstan_2.32.6 inline_0.3.21 ## [34] reshape2_1.4.4 rstantools_2.4.0 checkmate_2.3.2 ## [37] colorspace_2.1-1 assertthat_0.2.1 posterior_1.6.0 ## [40] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [43] stats4_4.4.2 lifecycle_1.0.4 stringr_1.5.1 ## [46] fs_1.6.5 htmlwidgets_1.6.4 ragg_1.3.3 ## [49] pkgconfig_2.0.3 desc_1.4.3 pkgdown_2.1.1 ## [52] RcppParallel_5.1.9 pillar_1.10.1 bslib_0.8.0 ## [55] gtable_0.3.6 loo_2.8.0 glue_1.8.0 ## [58] Rcpp_1.0.14 systemfonts_1.2.0 xfun_0.50 ## [61] tibble_3.2.1 tidyselect_1.2.1 farver_2.1.2 ## [64] htmltools_0.5.8.1 labeling_0.4.3 rmarkdown_2.29 ## [67] compiler_4.4.2 distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/articles/PoS_interim.html","id":"r-session-info","dir":"Articles","previous_headings":"","what":"R Session Info","title":"Probability of Success at an Interim Analysis","text":"","code":"## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] dplyr_1.1.4 scales_1.3.0 ggplot2_3.5.1 knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] sass_0.4.9 generics_0.1.3 digest_0.6.37 ## [4] magrittr_2.0.3 evaluate_1.0.3 grid_4.4.2 ## [7] mvtnorm_1.3-3 fastmap_1.2.0 jsonlite_1.8.9 ## [10] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [13] gridExtra_2.3 QuickJSR_1.5.1 codetools_0.2-20 ## [16] textshaping_0.4.1 jquerylib_0.1.4 abind_1.4-8 ## [19] cli_3.6.3 rlang_1.1.5 munsell_0.5.1 ## [22] withr_3.0.2 cachem_1.1.0 yaml_2.3.10 ## [25] StanHeaders_2.32.10 parallel_4.4.2 tools_4.4.2 ## [28] rstan_2.32.6 inline_0.3.21 rstantools_2.4.0 ## [31] checkmate_2.3.2 colorspace_2.1-1 assertthat_0.2.1 ## [34] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [37] stats4_4.4.2 lifecycle_1.0.4 fs_1.6.5 ## [40] htmlwidgets_1.6.4 ragg_1.3.3 pkgconfig_2.0.3 ## [43] desc_1.4.3 pkgdown_2.1.1 RcppParallel_5.1.9 ## [46] pillar_1.10.1 bslib_0.8.0 gtable_0.3.6 ## [49] loo_2.8.0 glue_1.8.0 Rcpp_1.0.14 ## [52] systemfonts_1.2.0 xfun_0.50 tibble_3.2.1 ## [55] tidyselect_1.2.1 farver_2.1.2 htmltools_0.5.8.1 ## [58] labeling_0.4.3 rmarkdown_2.29 compiler_4.4.2"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Customizing RBesT plots","text":"vignette demonstrates work forest plot provided RBesT package. show modify default plot , advanced users, extract data ggplot object create new plot scratch. Finally recreate plots case study presented training materials. general information plotting R, recommend following resources: bayesplot - library RBesT plotting functionality built ggplot2 - powerful library graphics R R Cookbook - Graphs - general reference R graphics R","code":"# Load required libraries library(RBesT) library(ggplot2) library(dplyr) ## ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ## ## filter, lag ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union library(tidyr) library(bayesplot) ## This is bayesplot version 1.11.1 ## - Online documentation and vignettes at mc-stan.org/bayesplot ## - bayesplot theme set to bayesplot::theme_default() ## * Does _not_ affect other ggplot2 plots ## * See ?bayesplot_theme_set for details on theme setting # Default settings for bayesplot color_scheme_set(\"blue\") theme_set(theme_default(base_size = 12)) # Load example gMAP object set.seed(546346) map_crohn <- gMAP(cbind(y, y.se) ~ 1 | study, family = gaussian, data = transform(crohn, y.se = 88 / sqrt(n)), weights = n, tau.dist = \"HalfNormal\", tau.prior = 44, beta.prior = cbind(0, 88) ) print(map_crohn) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(y, y.se) ~ 1 | study, family = gaussian, ## data = transform(crohn, y.se = 88/sqrt(n)), weights = n, ## tau.dist = \"HalfNormal\", tau.prior = 44, beta.prior = cbind(0, ## 88)) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## Estimated reference scale : 88 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 14.50 9.67 1.30 12.60 38.30 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## -50.5 19.4 -94.3 -49.0 -10.7"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"forest-plot","dir":"Articles","previous_headings":"","what":"Forest plot","title":"Customizing RBesT plots","text":"default forest plot “standard” forest plot Meta-Analytic-Predictive (MAP) prior additionally summarized bottom row: can also include model-based estimates study, add legend explain different linetypes. can modify color scheme follows (refer help(color_scheme_set) full list themes): point size can modified vertical line removed:","code":"forest_plot(map_crohn) forest_plot(map_crohn, model = \"both\") + legend_move(\"right\") # preview a color scheme color_scheme_view(\"mix-blue-red\") # and now let's use it color_scheme_set(\"mix-blue-red\") forest_plot(map_crohn) color_scheme_set(\"gray\") forest_plot(map_crohn) color_scheme_set(\"blue\") forest_plot(map_crohn, size = 0.5, alpha = 0)"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"presentation-ready-plots","dir":"Articles","previous_headings":"Forest plot","what":"Presentation-ready plots","title":"Customizing RBesT plots","text":"plot used presentation document study protocol, recommended use sufficiently large font sizes (e.g. large fonts slide document) elements plot clearly visible. show simple statements can used purpose. also recommend saving plots explicitly ggsave function, allows control (hence consistency) image size. Note font size enforced requested size; small image large font size may result little space plot . image sized according golden cut (ϕ=1+52≈1.62\\phi=\\frac{1+\\sqrt5}{2} \\approx 1.62) perceived pleasing axis ratio. Png recommended image file type presentations study documents.","code":"# adjust the base font size theme_set(theme_default(base_size = 16)) forest_plot(map_crohn, model = \"both\", est = \"MAP\", size = 1) + legend_move(\"right\") + labs( title = \"Forest plot\", subtitle = \"Results of Meta-Analytic-Predictive (MAP) analysis\", caption = \"Plot shows point estimates (posterior medians) with 95% intervals\" ) ggsave(\"plot1.png\", last_plot(), width = 1.62 * 2.78, height = 2.78, unit = \"in\") # too small for the chosen font size ggsave(\"plot2.png\", last_plot(), width = 1.62 * 5.56, height = 5.56, unit = \"in\") # fits a single ppt slide quite well"},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"extract-data-from-a-ggplot-object","dir":"Articles","previous_headings":"Advanced topics","what":"Extract data from a ggplot object","title":"Customizing RBesT plots","text":"situations, desired modifications plot provided RBesT may possible given returned ggplot object. truly tailored plot desired, user must extract data object create graph scratch using ggplot functions. Recall original forest plot: Suppose wish use different symbols meta/stratified point estimates different linestyle vertical line. tailored plot can created follows.","code":"# Extract the data from the returned object fp_data <- forest_plot(map_crohn)$data print(fp_data, digits = 2) ## mean sem median low up study model ## Gastr06 -51 10.2 -51 -71 -30.9 Gastr06 stratified ## AIMed07 -49 6.8 -49 -62 -35.6 AIMed07 stratified ## NEJM07 -36 4.9 -36 -46 -26.5 NEJM07 stratified ## Gastr01a -47 19.7 -47 -86 -8.4 Gastr01a stratified ## APhTh04 -90 17.6 -90 -124 -55.5 APhTh04 stratified ## Gastr01b -54 11.6 -54 -77 -31.4 Gastr01b stratified ## theta_resp_pred -50 19.4 -49 -94 -10.7 MAP meta ## theta_resp -50 8.6 -49 -69 -34.2 Mean meta # Use a two-component map mixture to compute the vertical line location map_mix <- mixfit(map_crohn, Nc = 2) # Finally compose a ggplot call for the desired graph ggplot(fp_data, aes(x = study, y = median, ymin = low, ymax = up, linetype = model, shape = model)) + geom_pointrange(size = 0.7, position = position_dodge(width = 0.5)) + geom_hline(yintercept = qmix(map_mix, 0.5), linetype = 3, alpha = 0.5) + coord_flip() + theme_bw(base_size = 12) + theme(legend.position = \"None\") + labs(x = \"\", y = \"Response\", title = \"Modified forest plot\")"},{"path":"https://opensource.nibr.com/RBesT/articles/customizing_plots.html","id":"design-plots-a-clinical-trial","dir":"Articles","previous_headings":"Advanced topics","what":"Design plots a clinical trial","title":"Customizing RBesT plots","text":"show create outcome operating characteristic plots clinical trial comparing developmental drug placebo. primary endpoint binary (event probability pp) use informative prior placebo arm event rate. experimental drug believed lower event rate, criteria study outcome hence follows: Criterion 1:Pr(ptrt/ppbo<1)>0.9Criterion 2:Pr(ptrt/ppbo<0.5)>0.5 \\begin{align*} \\textrm{Criterion 1:} \\Pr(p_{trt} / p_{pbo} < 1) &> 0.9\\\\ \\textrm{Criterion 2:} \\Pr(p_{trt} / p_{pbo} < 0.5) &> 0.5 \\end{align*} outcome success (GO) criteria satisfied, futility (STOP) neither satisfied, indeterminate one satisfied. now create plot shows study conclusion, given combination outcomes two treatment arms. can also use design functions already derived (design_suc design_fut) compute operating characteristics.","code":"# Define prior distributions prior_pbo <- mixbeta(inf1 = c(0.60, 19, 29), inf2 = c(0.30, 4, 5), rob = c(0.10, 1, 1)) prior_trt <- mixbeta(c(1, 1 / 3, 1 / 3)) # Study sample size n_trt <- 50 n_pbo <- 20 # Create decision rules and designs to represent success and futility success <- decision2S(pc = c(0.90, 0.50), qc = c(log(1), log(0.50)), lower.tail = TRUE, link = \"log\") futility <- decision2S(pc = c(0.10, 0.50), qc = c(log(1), log(0.50)), lower.tail = FALSE, link = \"log\") design_suc <- oc2S(prior_trt, prior_pbo, n_trt, n_pbo, success) design_fut <- oc2S(prior_trt, prior_pbo, n_trt, n_pbo, futility) crit_suc <- decision2S_boundary(prior_trt, prior_pbo, n_trt, n_pbo, success) crit_fut <- decision2S_boundary(prior_trt, prior_pbo, n_trt, n_pbo, futility) # Create a data frame that holds the outcomes for y1 (treatment) that define success and futility, # conditional on the number of events on y2 (placebo) outcomes <- data.frame(y2 = c(0:n_pbo), suc = crit_suc(0:n_pbo), fut = crit_fut(0:n_pbo), max = n_trt) outcomes$suc <- with(outcomes, ifelse(suc < 0, 0, suc)) # don't allow negative number of events # Finally put it all together in a plot. o <- 0.5 # offset ggplot(outcomes, aes(x = y2, ymin = -o, ymax = suc + o)) + geom_linerange(size = 4, colour = \"green\", alpha = 0.6) + geom_linerange(aes(ymin = suc + o, ymax = fut + o), colour = \"orange\", size = 4, alpha = 0.6) + geom_linerange(aes(ymin = fut + o, ymax = max + o), colour = \"red\", size = 4, alpha = 0.6) + annotate(\"text\", x = c(2, 14), y = c(36, 8), label = c(\"STOP\", \"GO\"), size = 10) + scale_x_continuous(breaks = seq(0, n_pbo, by = 2)) + scale_y_continuous(breaks = seq(0, n_trt, by = 4)) + labs(x = \"Events on placebo\", y = \"Events on treatment\", title = \"Study outcomes\") + coord_flip() + theme_bw(base_size = 12) ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. ## ℹ Please use `linewidth` instead. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated. # Define the grid of true event rates for which to evaluate OC p_trt <- seq(0, 0.5, length = 200) p_pbo <- c(0.35, 0.40, 0.45, 0.50) # Loop through the values for placebo and compute outcome probabilities oc_list <- lapply(p_pbo, function(x) { p_go <- design_suc(p_trt, x) p_stop <- design_fut(p_trt, x) data.frame(p_trt, p_pbo = x, Go = p_go, Stop = p_stop, Indeterminate = 1 - p_go - p_stop) }) # The above returns a list, so we bind the elements together into one data frame oc <- bind_rows(oc_list) # And convert from wide to long format oc <- gather(oc, \"Outcome\", \"Probability\", 3:5) oc$facet_text <- as.factor(paste(\"True placebo rate = \", oc$p_pbo, sep = \"\")) # Finally we are ready to plot ggplot(oc, aes(x = p_trt, y = Probability, colour = Outcome, linetype = Outcome)) + facet_wrap(~facet_text) + geom_line(size = 1) + scale_colour_manual(values = c(\"green\", \"orange\", \"red\"), name = \"Outcome\") + scale_linetype(guide = FALSE) + geom_hline(yintercept = c(0.1, 0.8), linetype = 3) + scale_y_continuous(breaks = seq(0, 1, by = 0.2)) + labs(x = \"True event rate for treatment\", y = \"Probability\", title = \"Operating Characteristics\") + theme_bw(base_size = 12) ## Warning: The `guide` argument in `scale_*()` cannot be `FALSE`. This was deprecated in ## ggplot2 3.3.4. ## ℹ Please use \"none\" instead. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated. sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] bayesplot_1.11.1 tidyr_1.3.1 dplyr_1.1.4 ggplot2_3.5.1 ## [5] knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] sass_0.4.9 generics_0.1.3 digest_0.6.37 ## [4] magrittr_2.0.3 evaluate_1.0.3 grid_4.4.2 ## [7] mvtnorm_1.3-3 fastmap_1.2.0 jsonlite_1.8.9 ## [10] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [13] gridExtra_2.3 purrr_1.0.2 QuickJSR_1.5.1 ## [16] scales_1.3.0 codetools_0.2-20 textshaping_0.4.1 ## [19] jquerylib_0.1.4 abind_1.4-8 cli_3.6.3 ## [22] crayon_1.5.3 rlang_1.1.5 munsell_0.5.1 ## [25] withr_3.0.2 cachem_1.1.0 yaml_2.3.10 ## [28] StanHeaders_2.32.10 parallel_4.4.2 tools_4.4.2 ## [31] rstan_2.32.6 inline_0.3.21 rstantools_2.4.0 ## [34] checkmate_2.3.2 colorspace_2.1-1 assertthat_0.2.1 ## [37] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [40] stats4_4.4.2 lifecycle_1.0.4 fs_1.6.5 ## [43] htmlwidgets_1.6.4 ragg_1.3.3 pkgconfig_2.0.3 ## [46] desc_1.4.3 pkgdown_2.1.1 RcppParallel_5.1.9 ## [49] pillar_1.10.1 bslib_0.8.0 gtable_0.3.6 ## [52] loo_2.8.0 glue_1.8.0 Rcpp_1.0.14 ## [55] systemfonts_1.2.0 xfun_0.50 tibble_3.2.1 ## [58] tidyselect_1.2.1 farver_2.1.2 htmltools_0.5.8.1 ## [61] labeling_0.4.3 rmarkdown_2.29 compiler_4.4.2"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting started with RBesT (binary)","text":"R Bayesian evidence synthesis Tools (RBesT) facilitate use historical information clinical trials. relevant historical information identified, RBesT supports derivation informative priors via Meta-Analytic-Predictive (MAP) approach [1] evaluation trial’s operating characteristics. MAP approach performs standard meta-analysis followed prediction control group parameter future study accounting uncertainty population mean (standard result meta-analysis) -trial heterogeneity. Therefore, RBesT can also used meta-analysis tool one simply neglects prediction part. document demonstrates RBesT can used derive historical control data prior binary endpoint. RBesT package homepage contains articles introductory material: Probability success co-data Probability success interim normal endpoint Customizing RBesT plots RBesT normal endpoint Meta-Analytic-Predictive priors variances","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"binary-responder-analysis-example","dir":"Articles","previous_headings":"","what":"Binary responder analysis example","title":"Getting started with RBesT (binary)","text":"Let’s consider Novartis Phase II study ankylosing spondylitis comparing Novartis test treatment secukinumab placebo [2]. primary efficacy endpoint percentage patients 20% response according Assessment SpondyloArthritis international Society criteria improvement (ASAS20) week 6. control group, following historical data used derive MAP prior: dataset part RBesT available loading package data frame . RBesT supports required steps design clinical trial historical information using MAP approach.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"meta-analytic-predictive-analysis","dir":"Articles","previous_headings":"Prior Derivation","what":"Meta-Analytic-Predictive Analysis","title":"Getting started with RBesT (binary)","text":"gMAP function performs meta-analysis prediction, yields MAP prior. analysis run using stochastic Markov-Chain-Monte-Carlo Stan. order make results exactly reproducible, set.seed function must called prior calling gMAP . key parameter meta-analysis -trial heterogeneity parameter τ\\tau controls amount borrowing historical information estimation population mean occur. often historical trials, prior important. binary endpoints expected response rate 20%-80% recommend conservative HalfNormal(0,1) prior default. Please refer help-page gMAP information. gMAP function returns analysis object can extract information using functions RBesT. recommend look graphical model checks provided RBesT demonstrated . important one forest plot, solid lines MAP model predictions dashed lines stratified estimates. standard forest plot without shrinkage estimates please refer forest_plot function RBesT. often raised concern Bayesian analysis choice prior. Hence sensitivity analyses may sometimes necessary. can quickly performed update function. Suppose want evaluate optimistic scenario (less -trial heterogeneity), expressed HalfNormal(0,1/2) prior τ\\tau. can rerun original analysis, modified arguments gMAP:","code":"# load R packages library(RBesT) library(ggplot2) theme_set(theme_bw()) # sets up plotting theme set.seed(34563) map_mcmc <- gMAP(cbind(r, n - r) ~ 1 | study, data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2, family = binomial ) ## Assuming default prior location for beta: 0 print(map_mcmc) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(r, n - r) ~ 1 | study, family = binomial, ## data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 0.3770 0.2170 0.0414 0.3460 0.8930 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## 0.2580 0.0842 0.1120 0.2510 0.4590 ## a graphical representation of model checks is available pl <- plot(map_mcmc) ## a number of plots are immediately defined names(pl) ## [1] \"densityThetaStar\" \"densityThetaStarLink\" \"forest_model\" ## forest plot with model estimates print(pl$forest_model) set.seed(36546) map_mcmc_sens <- update(map_mcmc, tau.prior = 1 / 2) ## Assuming default prior location for beta: 0 print(map_mcmc_sens) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(r, n - r) ~ 1 | study, family = binomial, ## data = AS, tau.dist = \"HalfNormal\", tau.prior = 1/2, beta.prior = 2) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 0.3350 0.1750 0.0416 0.3140 0.7280 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## 0.2560 0.0786 0.1200 0.2470 0.4390"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"parametric-approximation","dir":"Articles","previous_headings":"Prior Derivation","what":"Parametric Approximation","title":"Getting started with RBesT (binary)","text":"next step, MAP prior, represented numerically using large MCMC simulation sample, converted parametric representation automixfit function. function fits parametric mixture representation using expectation-maximization (EM). number mixture components best describe MAP chosen automatically. , plot function produces graphical diagnostic allows user assess whether marginal mixture density (shown black) matches well histogram MAP MCMC sample.","code":"map <- automixfit(map_mcmc) print(map) ## EM for Beta Mixture Model ## Log-Likelihood = 4523.865 ## ## Univariate beta mixture ## Mixture Components: ## comp1 comp2 ## w 0.6167463 0.3832537 ## a 19.1916387 3.5278745 ## b 57.7779318 9.3735980 plot(map)$mix"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"effective-sample-size","dir":"Articles","previous_headings":"Prior Derivation","what":"Effective Sample Size","title":"Getting started with RBesT (binary)","text":"(usual) intended use (MAP) prior reduce number control patients trial. prior can considered equivalent number experimental observations, called effective sample size (ESS) prior. can calculated RBesT ess function. noted, however, concept ESS somewhat elusive. particular, definition ESS unique multiple methods therefore implemented RBesT. default method RBesT elir approach [5] results reasonable ESS estimates. moment matching approach leads conservative (small) ESS estimates Morita [3] method tends estimates liberal (large) ESS estimates used mixtures: Morita approach uses curvature prior mode found sensitive large number mixture components. experience, realistic ESS estimate can obtained elir method method predictively consistent, see [5] details.","code":"round(ess(map, method = \"elir\")) ## default method ## [1] 37 round(ess(map, method = \"moment\")) ## [1] 26 round(ess(map, method = \"morita\")) ## [1] 63"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"robustification-of-the-map-prior","dir":"Articles","previous_headings":"Prior Derivation","what":"Robustification of the MAP Prior","title":"Getting started with RBesT (binary)","text":"Finally, recommend robustify [4] prior protects type-error inflation presence prior-data conflict, .e. future trial data strongly deviate historical control information. Adding robust mixture component reduce ESS MAP prior extent depends weight robust component. Selecting higher robust mixture weights leads greater discounting informative MAP prior vice versa. consequence robust weight controls degree influence MAP prior within final analysis. circumstances can helpful graphically illustrate relationship prior ESS function robust mixture component weight:","code":"## add a 20% non-informative mixture component map_robust <- robustify(map, weight = 0.2, mean = 1 / 2) print(map_robust) ## Univariate beta mixture ## Mixture Components: ## comp1 comp2 robust ## w 0.493397 0.306603 0.200000 ## a 19.191639 3.527875 1.000000 ## b 57.777932 9.373598 1.000000 round(ess(map_robust)) ## [1] 26 ess_weight <- data.frame(weight = seq(0.05, 0.95, by = 0.05), ess = NA) for (i in seq_along(ess_weight$weight)) { ess_weight$ess[i] <- ess(robustify(map, ess_weight$weight[i], 0.5)) } ess_weight <- rbind( ess_weight, data.frame( weight = c(0, 1), ess = c(ess(map), ess(mixbeta(c(1, 1, 1)))) ) ) ggplot(ess_weight, aes(weight, ess)) + geom_point() + geom_line() + ggtitle(\"ESS of robust MAP for varying weight of robust component\") + scale_x_continuous(breaks = seq(0, 1, by = 0.1)) + scale_y_continuous(breaks = seq(0, 40, by = 5))"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"design-evaluation","dir":"Articles","previous_headings":"","what":"Design Evaluation","title":"Getting started with RBesT (binary)","text":"Now prior can specified protocol. advantage using historical information possible reduction placebo patient group. sample size control group supplemented historical information. reduction placebo patients can large ESS MAP prior. following, compare designs different sample sizes priors control group. comparisons carried evaluating standard Frequentist operating characteristics (type-error, power). scenarios exhaustive, rather specific ones demonstrate use RBesT design evaluation.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"operating-characteristics","dir":"Articles","previous_headings":"Design Evaluation","what":"Operating Characteristics","title":"Getting started with RBesT (binary)","text":"consider 2-arm design actual Novartis trial ankylosing spondylitis [2]. trial tested 6 patients placebo control 24 patients active experimental treatment. Success declared whenever condition Pr(θactive−θcontrol>0)>0.95\\Pr(\\theta_{active} - \\theta_{control} > 0) > 0.95 met response rates θactive\\theta_{active} θcontrol\\theta_{control}. MAP prior used placebo response rate parameter. evaluate design options example. operating characteristics setup RBesT stepwise manner: Definition priors arm. Definition decision criterion using decision2S function. Specification design options oc2S function. includes overall decision function per arm prior sample size use. object step 3 used calculate operating characteristics. Note 1-sample situation respective decision1S oc1S function used instead.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"type-i-error","dir":"Articles","previous_headings":"Design Evaluation > Operating Characteristics","what":"Type I Error","title":"Getting started with RBesT (binary)","text":"type can increased compared nominal α\\alpha level case conflict trial data prior. Note, example MAP prior 95% interval 0.1 0.5. Note observing response rates greater 50% highly implausible based MAP analysis: Hence, resonable restrict response rates θ\\theta evaluate type error range plausible values:","code":"theta <- seq(0.1, 0.95, by = 0.01) uniform_prior <- mixbeta(c(1, 1, 1)) treat_prior <- mixbeta(c(1, 0.5, 1)) # prior for treatment used in trial lancet_prior <- mixbeta(c(1, 11, 32)) # prior for control used in trial decision <- decision2S(0.95, 0, lower.tail = FALSE) design_uniform <- oc2S(uniform_prior, uniform_prior, 24, 6, decision) design_classic <- oc2S(uniform_prior, uniform_prior, 24, 24, decision) design_nonrobust <- oc2S(treat_prior, map, 24, 6, decision) design_robust <- oc2S(treat_prior, map_robust, 24, 6, decision) typeI_uniform <- design_uniform(theta, theta) typeI_classic <- design_classic(theta, theta) typeI_nonrobust <- design_nonrobust(theta, theta) typeI_robust <- design_robust(theta, theta) ocI <- rbind( data.frame(theta = theta, typeI = typeI_robust, prior = \"robust\"), data.frame(theta = theta, typeI = typeI_nonrobust, prior = \"non-robust\"), data.frame(theta = theta, typeI = typeI_uniform, prior = \"uniform\"), data.frame(theta = theta, typeI = typeI_classic, prior = \"uniform 24:24\") ) ggplot(ocI, aes(theta, typeI, colour = prior)) + geom_line() + ggtitle(\"Type I Error\") summary(map) ## mean sd 2.5% 50.0% 97.5% ## 0.25857963 0.08423297 0.10808237 0.25003652 0.47028444 ggplot(ocI, aes(theta, typeI, colour = prior)) + geom_line() + ggtitle(\"Type I Error - response rate restricted to plausible range\") + coord_cartesian(xlim = c(0, 0.5))"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"power","dir":"Articles","previous_headings":"Design Evaluation > Operating Characteristics","what":"Power","title":"Getting started with RBesT (binary)","text":"power demonstrates gain using informative prior; .e. 80% power reached smaller δ\\delta values comparison design non-informative priors arms. see MAP prior one reaches greater power smaller differences δ\\delta response rate. example, δ\\delta 80% power reached can found :","code":"delta <- seq(0, 0.7, by = 0.01) mean_control <- summary(map)[\"mean\"] theta_active <- mean_control + delta theta_control <- mean_control + 0 * delta power_uniform <- design_uniform(theta_active, theta_control) power_classic <- design_classic(theta_active, theta_control) power_nonrobust <- design_nonrobust(theta_active, theta_control) power_robust <- design_robust(theta_active, theta_control) ocP <- rbind( data.frame(theta_active, theta_control, delta = delta, power = power_robust, prior = \"robust\"), data.frame(theta_active, theta_control, delta = delta, power = power_nonrobust, prior = \"non-robust\"), data.frame(theta_active, theta_control, delta = delta, power = power_uniform, prior = \"uniform\"), data.frame(theta_active, theta_control, delta = delta, power = power_classic, prior = \"uniform 24:24\") ) ggplot(ocP, aes(delta, power, colour = prior)) + geom_line() + ggtitle(\"Power\") find_delta <- function(design, theta_control, target_power) { uniroot( function(delta) { design(theta_control + delta, theta_control) - target_power }, interval = c(0, 1 - theta_control) )$root } target_effect <- data.frame( delta = c( find_delta(design_nonrobust, mean_control, 0.8), find_delta(design_classic, mean_control, 0.8), find_delta(design_robust, mean_control, 0.8), find_delta(design_uniform, mean_control, 0.8) ), prior = c(\"non-robust\", \"uniform 24:24\", \"robust\", \"uniform\") ) knitr::kable(target_effect, digits = 3)"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"data-scenarios","dir":"Articles","previous_headings":"Design Evaluation > Operating Characteristics","what":"Data Scenarios","title":"Getting started with RBesT (binary)","text":"alternative approach visualize study design non-statisticians considering data scenarios. show decisions based potential trial outcomes. information needed critical values decision criterion flips. 2-sample case means calculate decision boundary, see decision2S_boundary help information. graph shows decision always negative less 10 events treatment group. hand, non-robust prior assuming 15 events treatment group, three (less) placebo events needed success. check result, can directly evaluate decision function:","code":"## Critical values at which the decision flips are given conditional ## on the outcome of the second read-out; as we like to have this as a ## function of the treatment group outcome, we flip label 1 and 2 decision_flipped <- decision2S(0.95, 0, lower.tail = TRUE) crit_uniform <- decision2S_boundary(uniform_prior, uniform_prior, 6, 24, decision_flipped) crit_nonrobust <- decision2S_boundary(map, treat_prior, 6, 24, decision_flipped) crit_robust <- decision2S_boundary(map_robust, treat_prior, 6, 24, decision_flipped) treat_y2 <- 0:24 ## Note that -1 is returned to indicated that the decision is never 1 ocC <- rbind( data.frame(y2 = treat_y2, y1_crit = crit_robust(treat_y2), prior = \"robust\"), data.frame(y2 = treat_y2, y1_crit = crit_nonrobust(treat_y2), prior = \"non-robust\"), data.frame(y2 = treat_y2, y1_crit = crit_uniform(treat_y2), prior = \"uniform\") ) ggplot(ocC, aes(y2, y1_crit, colour = prior)) + geom_step() + ggtitle(\"Critical values y1(y2)\") ## just positive decision(postmix(treat_prior, n = 24, r = 15), postmix(map, n = 6, r = 3)) ## [1] 1 ## negative decision(postmix(treat_prior, n = 24, r = 14), postmix(map, n = 6, r = 4)) ## [1] 0"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"trial-analysis","dir":"Articles","previous_headings":"","what":"Trial Analysis","title":"Getting started with RBesT (binary)","text":"trial completed data collected, final analysis can run RBesT using postmix function. Calculations performed analytically conjugate mixture setting.","code":"r_placebo <- 1 r_treat <- 14 ## first obtain posterior distributions... post_placebo <- postmix(map_robust, r = r_placebo, n = 6) post_treat <- postmix(treat_prior, r = r_treat, n = 24) ## ...then calculate probability that the difference is smaller than ## zero prob_smaller <- pmixdiff(post_treat, post_placebo, 0, lower.tail = FALSE) prob_smaller ## [1] 0.9913233 prob_smaller > 0.95 ## [1] TRUE ## alternativley we can use the decision object decision(post_treat, post_placebo) ## [1] 1"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"references","dir":"Articles","previous_headings":"Trial Analysis","what":"References","title":"Getting started with RBesT (binary)","text":"[1] Neuenschwander B. et al., Clin Trials. 2010; 7(1):5-18 [2] Baeten D. et al., Lancet, 2013, (382), 9906, p 1705 [3] Morita S. et al., Biometrics 2008;64(2):595-602 [4] Schmidli H. et al., Biometrics 2014;70(4):1023-1032 [5] Neuenschwander B. et al., Biometrics 2020;76(2):578-587","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction.html","id":"r-session-info","dir":"Articles","previous_headings":"Trial Analysis","what":"R Session Info","title":"Getting started with RBesT (binary)","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] ggplot2_3.5.1 knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 rlang_1.1.5 ## [25] munsell_0.5.1 withr_3.0.2 cachem_1.1.0 ## [28] yaml_2.3.10 StanHeaders_2.32.10 parallel_4.4.2 ## [31] tools_4.4.2 rstan_2.32.6 inline_0.3.21 ## [34] reshape2_1.4.4 rstantools_2.4.0 checkmate_2.3.2 ## [37] dplyr_1.1.4 colorspace_2.1-1 assertthat_0.2.1 ## [40] posterior_1.6.0 vctrs_0.6.5 R6_2.5.1 ## [43] matrixStats_1.5.0 stats4_4.4.2 lifecycle_1.0.4 ## [46] stringr_1.5.1 fs_1.6.5 htmlwidgets_1.6.4 ## [49] ragg_1.3.3 pkgconfig_2.0.3 desc_1.4.3 ## [52] pkgdown_2.1.1 RcppParallel_5.1.9 pillar_1.10.1 ## [55] bslib_0.8.0 gtable_0.3.6 loo_2.8.0 ## [58] glue_1.8.0 Rcpp_1.0.14 systemfonts_1.2.0 ## [61] xfun_0.50 tibble_3.2.1 tidyselect_1.2.1 ## [64] farver_2.1.2 bayesplot_1.11.1 htmltools_0.5.8.1 ## [67] labeling_0.4.3 rmarkdown_2.29 compiler_4.4.2 ## [70] distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"RBesT for a Normal Endpoint","text":"R Bayesian evidence synthesis Tools (RBesT) created facilitate use historical information clinical trials. relevant historical information identified, RBesT supports derivation informative priors via Meta-Analytic-Predictive (MAP) approach [1], evaluation trial’s operating characteristics, data analysis actual trial data. RBesT developed endpoints number well known distributions. consider example normally distributed response variable.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"historical-data","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Historical Data","title":"RBesT for a Normal Endpoint","text":"Let’s look Crohn’s disease example data [2] (data-set crohn RBesT). primary endpoint change baseline Crohn’s Disease Activity Index (CDAI), assumed normally distributed. Note CDAI, improved outcome corresponds negative change baseline. First historical studies get estimated standard deviation response variable σ\\sigma = 88, used obtain standard errors effect estimates.","code":"dat <- crohn crohn_sigma <- 88 dat$y.se <- crohn_sigma / sqrt(dat$n)"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"derivation-of-map-prior","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Derivation of MAP Prior","title":"RBesT for a Normal Endpoint","text":"MAP prior can derived function gMAP. -trial heterogeneity parameter τ\\tau governs much information shared historical trials design analysis future trials. normal case known sampling standard deviation σ\\sigma, amount borrowing historical data depends ratio τ/σ\\tau/\\sigma. conservative choice prior τ\\tau HalfNormal(0, σ/2\\sigma/2) distribution. prior intercept recommend “unit-information” prior [3] set precision corresponding single observation centered change baseline. Please refer help page ?gMAP detailed information. set.seed function used make results exactly reproducible.","code":"library(RBesT) set.seed(689654) map_mcmc <- gMAP(cbind(y, y.se) ~ 1 | study, weights = n, data = dat, family = gaussian, beta.prior = cbind(0, crohn_sigma), tau.dist = \"HalfNormal\", tau.prior = cbind(0, crohn_sigma / 2) ) print(map_mcmc) ## Generalized Meta Analytic Predictive Prior Analysis ## ## Call: gMAP(formula = cbind(y, y.se) ~ 1 | study, family = gaussian, ## data = dat, weights = n, tau.dist = \"HalfNormal\", tau.prior = cbind(0, ## crohn_sigma/2), beta.prior = cbind(0, crohn_sigma)) ## ## Exchangeability tau strata: 1 ## Prediction tau stratum : 1 ## Maximal Rhat : 1 ## Estimated reference scale : 88 ## ## Between-trial heterogeneity of tau prediction stratum ## mean sd 2.5% 50% 97.5% ## 14.30 9.38 1.54 12.20 36.80 ## ## MAP Prior MCMC sample ## mean sd 2.5% 50% 97.5% ## -49.7 18.6 -88.4 -48.7 -12.3 ## a graphical representation is also available pl <- plot(map_mcmc) ## a number of plots are immediately defined names(pl) ## [1] \"densityThetaStar\" \"densityThetaStarLink\" \"forest_model\" ## forest plot with model estimates print(pl$forest_model)"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"approximation-of-map-prior-using-a-mixture-distribution","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Approximation of MAP Prior using a Mixture Distribution","title":"RBesT for a Normal Endpoint","text":"Next, MCMC MAP prior previous section converted parametric representation automixfit function. function fits parametric mixture representation using expectation-maximization (EM). number mixture components chosen automatically using AIC. One can also specify number components mixture via mixfit function compare automixfit outcome.","code":"map <- automixfit(map_mcmc) print(map) ## EM for Normal Mixture Model ## Log-Likelihood = -17021.66 ## ## Univariate normal mixture ## Reference scale: 88 ## Mixture Components: ## comp1 comp2 comp3 ## w 0.4366963 0.4324896 0.1308141 ## m -47.7396255 -51.3051003 -51.1267753 ## s 8.4310808 18.1462655 36.1496171 ## check accuracy of mixture fit plot(map)$mix"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"effective-sample-size-ess","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Effective Sample Size (ESS)","title":"RBesT for a Normal Endpoint","text":"main advantage using historical information possibility reduce number control patients, informative prior effectively equivalent certain number control patients. called effective sample size (ESS) can calculated RBesT ess function. study protocol Crohn’s disease data example, conservative moment-based ESS 20 used reduce planned sample size control group.","code":"round(ess(map)) ## default elir method ## Using default prior reference scale 88 ## [1] 37 round(ess(map, method = \"morita\")) ## Using default prior reference scale 88 ## [1] 78 round(ess(map, method = \"moment\")) ## Using default prior reference scale 88 ## [1] 22"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"robustification-of-map-prior","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Robustification of MAP Prior","title":"RBesT for a Normal Endpoint","text":"recommend robustifying [5] prior robustify function, protects type-error inflation presence prior-data conflict. normal case strongly recommend explicitly choosing mean robust component. use −50-50 consistent mean MAP prior. Furthermore, 20% probability used additional robust (unit-information) mixture component. choice probability reflects confidence validitiy model assumptions, .e. possibility non-exchangable control group enrolled per inclusion/exclusion criteria current trial compared historical control group population. Note robustification decreases ESS.","code":"## add a 20% non-informative mixture component map_robust <- robustify(map, weight = 0.2, mean = -50) ## Using default prior reference scale 88 print(map_robust) ## Univariate normal mixture ## Reference scale: 88 ## Mixture Components: ## comp1 comp2 comp3 robust ## w 0.3493570 0.3459917 0.1046513 0.2000000 ## m -47.7396255 -51.3051003 -51.1267753 -50.0000000 ## s 8.4310808 18.1462655 36.1496171 88.0000000 round(ess(map_robust)) ## Using default prior reference scale 88 ## [1] 27"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"operating-characteristics-of-design-options","dir":"Articles","previous_headings":"Trial Design with Historical Control Data","what":"Operating Characteristics of Design Options","title":"RBesT for a Normal Endpoint","text":"Typically, operating characteristics required evaluate proposed design compare design options. RBesT requires input decision rules via decision2S function calculates operating characteristics oc2S function. calculation expedited based analytic expressions. following compare design options, differ choice control priors sample size control group planned trial. may design factors (outcome standard deviation), considered comparing design options. factors considered simplicity purpose.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"decision-rules","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Decision Rules","title":"RBesT for a Normal Endpoint","text":"Consider 2-arm design placebo (informative prior) experimental treatment. dual-criterion success defined follows: Criterion 1:Pr(θact−θpbo<0)>0.95Criterion 2:Pr(θact−θpbo<−50)>0.50. \\begin{align*} \\textrm{Criterion 1:} & \\Pr(\\theta_{act} - \\theta_{pbo} \\lt 0) &> 0.95 \\\\ \\textrm{Criterion 2:} & \\Pr(\\theta_{act} - \\theta_{pbo} \\lt -50) &> 0.50. \\end{align*} Equivalently, second criterion requires posterior median difference exceeds -50. dual-criteria account statistical significance well clinical relevance. Note negative change baseline CDAI corresponds improvement.","code":"## dual decision criteria ## pay attention to \"lower.tail\" argument and the order of active and pbo poc <- decision2S(pc = c(0.95, 0.5), qc = c(0, -50), lower.tail = TRUE) print(poc) ## 2 sample decision function ## Conditions for acceptance: ## P(theta1 - theta2 <= 0) > 0.95 ## P(theta1 - theta2 <= -50) > 0.5 ## Link: identity"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"design-options","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Design Options","title":"RBesT for a Normal Endpoint","text":"active group use weakly informative (unit-information) prior used robustification step MAP prior. Also, set design options different choices control prior different sizes control group.","code":"## set up prior for active group weak_prior <- mixnorm(c(1, -50, 1), sigma = crohn_sigma, param = \"mn\") n_act <- 40 n_pbo <- 20 ## four designs ## \"b\" means a balanced design, 1:1 ## \"ub\" means 40 in active and 20 in placebo design_noprior_b <- oc2S(weak_prior, weak_prior, n_act, n_act, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma ) design_noprior_ub <- oc2S(weak_prior, weak_prior, n_act, n_pbo, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma ) design_nonrob_ub <- oc2S(weak_prior, map, n_act, n_pbo, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma ) design_rob_ub <- oc2S(weak_prior, map_robust, n_act, n_pbo, poc, sigma1 = crohn_sigma, sigma2 = crohn_sigma )"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"type-i-error","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Type I Error","title":"RBesT for a Normal Endpoint","text":"type can increased compared nominal α\\alpha level case conflict trial data prior. robustified MAP prior can reduce type error inflation case lower level.","code":"# the range for true values cfb_truth <- seq(-120, -40, by = 1) typeI1 <- design_noprior_b(cfb_truth, cfb_truth) typeI2 <- design_noprior_ub(cfb_truth, cfb_truth) typeI3 <- design_nonrob_ub(cfb_truth, cfb_truth) typeI4 <- design_rob_ub(cfb_truth, cfb_truth) ocI <- rbind( data.frame( cfb_truth = cfb_truth, typeI = typeI1, design = \"40:40 with non-informative priors\" ), data.frame( cfb_truth = cfb_truth, typeI = typeI2, design = \"40:20 with non-informative priors\" ), data.frame( cfb_truth = cfb_truth, typeI = typeI3, design = \"40:20 with non-robust prior for placebo\" ), data.frame( cfb_truth = cfb_truth, typeI = typeI4, design = \"40:20 with robust prior for placebo\" ) ) ggplot(ocI, aes(cfb_truth, typeI, colour = design)) + geom_line() + ggtitle(\"Type I Error\") + xlab(expression(paste(\"True value of change from baseline \", mu[act] == mu[pbo]))) + ylab(\"Type I error\") + coord_cartesian(ylim = c(0, 0.2)) + theme(legend.justification = c(1, 1), legend.position = c(0.95, 0.85)) ## Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2 ## 3.5.0. ## ℹ Please use the `legend.position.inside` argument of `theme()` instead. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated."},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"power","dir":"Articles","previous_headings":"Trial Design with Historical Control Data > Operating Characteristics of Design Options","what":"Power","title":"RBesT for a Normal Endpoint","text":"power shows gain using informative prior control arm; .e. 90% power reached smaller δ\\delta values compared design weakly informative priors arms balanced design.","code":"delta <- seq(-80, 0, by = 1) m <- summary(map)[\"mean\"] cfb_truth1 <- m + delta # active for 1 cfb_truth2 <- m + 0 * delta # pbo for 2 power1 <- design_noprior_b(cfb_truth1, cfb_truth2) power2 <- design_noprior_ub(cfb_truth1, cfb_truth2) power3 <- design_nonrob_ub(cfb_truth1, cfb_truth2) power4 <- design_rob_ub(cfb_truth1, cfb_truth2) ocP <- rbind( data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power1, design = \"40:40 with non-informative priors\" ), data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power2, design = \"40:20 with non-informative priors\" ), data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power3, design = \"40:20 with non-robust prior for placebo\" ), data.frame( cfb_truth1 = cfb_truth1, cfb_truth2 = cfb_truth2, delta = delta, power = power4, design = \"40:20 with robust prior for placebo\" ) ) ggplot(ocP, aes(delta, power, colour = design)) + geom_line() + ggtitle(\"Power\") + xlab(\"True value of difference (act - pbo)\") + ylab(\"Power\") + scale_y_continuous(breaks = c(seq(0, 1, 0.2), 0.9)) + scale_x_continuous(breaks = c(seq(-80, 0, 20), -70)) + geom_hline(yintercept = 0.9, linetype = 2) + geom_vline(xintercept = -70, linetype = 2) + theme(legend.justification = c(1, 1), legend.position = c(0.95, 0.85))"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"final-analysis-with-trial-data","dir":"Articles","previous_headings":"","what":"Final Analysis with Trial Data","title":"RBesT for a Normal Endpoint","text":"actual trial data available, final analysis can run RBesT via postmix function. real data used example, trial data led negative conclusion. However, note postmix assumes sampling standard deviation known fixed. Therefore, uncertainty estimate taken account.","code":"## one can either use summary data or individual data. See ?postmix. y.act <- -29.2 y.act.se <- 14.0 n.act <- 39 y.pbo <- -63.1 y.pbo.se <- 13.9 n.pbo <- 20 ## first obtain posterior distributions post_act <- postmix(weak_prior, m = y.act, se = y.act.se) post_pbo <- postmix(map_robust, m = y.pbo, se = y.pbo.se) ## then calculate probability for the dual criteria ## and compare to the predefined threshold values p1 <- pmixdiff(post_act, post_pbo, 0) print(p1) ## [1] 0.06149329 p2 <- pmixdiff(post_act, post_pbo, -50) print(p2) ## [1] 3.795469e-06 print(p1 > 0.95 & p2 > 0.5) ## [1] FALSE ## or we can use the decision function poc(post_act, post_pbo) ## [1] 0"},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"references","dir":"Articles","previous_headings":"Final Analysis with Trial Data","what":"References","title":"RBesT for a Normal Endpoint","text":"[1] Neuenschwander B et. al, Clin Trials. 2010; 7(1):5-18 [2] Hueber W. et. al, Gut, 2012, 61(12):1693-1700 [3] Kass RE, Wasserman L, J Amer Statist Assoc; 1995, 90(431):928-934. [4] Morita S. et. al, Biometrics 2008;64(2):595-602 [5] Schmidli H. et. al, Biometrics 2014;70(4):1023-1032","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/introduction_normal.html","id":"r-session-info","dir":"Articles","previous_headings":"Final Analysis with Trial Data","what":"R Session Info","title":"RBesT for a Normal Endpoint","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] ggplot2_3.5.1 knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 crayon_1.5.3 ## [25] rlang_1.1.5 munsell_0.5.1 withr_3.0.2 ## [28] cachem_1.1.0 yaml_2.3.10 StanHeaders_2.32.10 ## [31] parallel_4.4.2 tools_4.4.2 rstan_2.32.6 ## [34] inline_0.3.21 reshape2_1.4.4 rstantools_2.4.0 ## [37] checkmate_2.3.2 dplyr_1.1.4 colorspace_2.1-1 ## [40] assertthat_0.2.1 posterior_1.6.0 vctrs_0.6.5 ## [43] R6_2.5.1 matrixStats_1.5.0 stats4_4.4.2 ## [46] lifecycle_1.0.4 stringr_1.5.1 fs_1.6.5 ## [49] htmlwidgets_1.6.4 ragg_1.3.3 pkgconfig_2.0.3 ## [52] desc_1.4.3 pkgdown_2.1.1 RcppParallel_5.1.9 ## [55] pillar_1.10.1 bslib_0.8.0 gtable_0.3.6 ## [58] loo_2.8.0 glue_1.8.0 Rcpp_1.0.14 ## [61] systemfonts_1.2.0 xfun_0.50 tibble_3.2.1 ## [64] tidyselect_1.2.1 farver_2.1.2 bayesplot_1.11.1 ## [67] htmltools_0.5.8.1 labeling_0.4.3 rmarkdown_2.29 ## [70] compiler_4.4.2 distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"map-prior-for-the-sampling-standard-deviation","dir":"Articles","previous_headings":"","what":"MAP prior for the sampling standard deviation","title":"Meta-Analytic-Predictive Priors for Variances","text":"MAP analysis performed log\\log variance, actually interested MAP respective sampling standard deviation. Since sampling standard deviation strictly positive quantity suitable approximate MCMC posterior MAP prior using mixture Γ\\Gamma variates, can done using RBesT :","code":"map_mc_post <- as.matrix(map_mc) sd_trans <- compose(sqrt, exp) mcmc_intervals(map_mc_post, regex_pars = \"theta\", transformation = sd_trans) map_sigma_mc <- sd_trans(map_mc_post[, c(\"theta_pred\")]) map_sigma <- automixfit(map_sigma_mc, type = \"gamma\") plot(map_sigma)$mix ## 95% interval MAP for the sampling standard deviation summary(map_sigma) ## mean sd 2.5% 50.0% 97.5% ## 10.980236 1.401089 8.283373 10.921528 14.063679"},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"normal-approximation-of-a-loggamma-variate","dir":"Articles","previous_headings":"","what":"Normal approximation of a logΓ\\log\\Gamma variate","title":"Meta-Analytic-Predictive Priors for Variances","text":"Γ(y|α,β)\\Gamma(y|\\alpha, \\beta) variate yy, log\\log transformed, z=log(y)z = \\log(y), law transformations univariate densities: y|α,β∼Γ(α,β) y|\\alpha,\\beta \\sim \\Gamma(\\alpha,\\beta) p(z)=p(y)y=p(exp(z))exp(z) p(z) = p(y) \\, y = p(\\exp(z)) \\, \\exp(z) z|α,β∼logΓ(α,β) z|\\alpha,\\beta \\sim \\log\\Gamma(\\alpha,\\beta)⇔exp(z)|α,β∼Γ(α,β)exp(z)\\Leftrightarrow \\exp(z)|\\alpha,\\beta \\sim \\Gamma(\\alpha,\\beta) \\, \\exp(z) first second moment zz E[z]=ψ(α)−log(β) E[z] = \\psi(\\alpha) - \\log(\\beta)Var[z]=ψ(1)(α). Var[z] = \\psi^{(1)}(\\alpha). short simulation demonstrates results: see ν=9\\nu=9 , approximation normal density reasonable. However, comparing function ν\\nu 2.52.5%, 5050% 97.597.5% quantiles correct distribution respective approximate distribution can assess adequatness approximation. respective R code accessible via vignette overview page graphical result presented two different σ\\sigma values:","code":"gamma_dist <- mixgamma(c(1, 18, 6)) ## logGamma density dlogGamma <- function(z, a, b, log = FALSE) { n <- exp(z) if (!log) { return(dgamma(n, a, b) * n) } else { return(dgamma(n, a, b, log = TRUE) + z) } } a <- gamma_dist[2, 1] b <- gamma_dist[3, 1] m <- digamma(a) - log(b) v <- psigamma(a, 1) ## compare simulated histogram of log transformed Gamma variates to ## analytic density and approximate normal sim <- rmix(gamma_dist, 1E5) mcmc_hist(data.frame(logGamma = log(sim)), freq = FALSE, binwidth = 0.1) + overlay_function(fun = dlogGamma, args = list(a = a, b = b), aes(linetype = \"LogGamma\")) + overlay_function(fun = dnorm, args = list(mean = m, sd = sqrt(v)), aes(linetype = \"NormalApprox\")) ## Warning in stat_function(..., inherit.aes = FALSE): All aesthetics have length 1, but the data has 100000 rows. ## ℹ Please consider using `annotate()` or provide this layer with data containing ## a single row. ## All aesthetics have length 1, but the data has 100000 rows. ## ℹ Please consider using `annotate()` or provide this layer with data containing ## a single row."},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"acknowledgements","dir":"Articles","previous_headings":"Normal approximation of a logΓ\\log\\Gamma variate","what":"Acknowledgements","title":"Meta-Analytic-Predictive Priors for Variances","text":"Many thanks Ping Chen Simon Wandel pointing issue transformation used earlier vignette.","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"references","dir":"Articles","previous_headings":"Normal approximation of a logΓ\\log\\Gamma variate","what":"References","title":"Meta-Analytic-Predictive Priors for Variances","text":"[1] Schmidli, H., et. al, Comp. Stat. Data Analysis, 2017, 113:100-110 [2] https://en.wikipedia.org/wiki/Gamma_distribution#Logarithmic_expectation_and_variance [3] Gelman , et. al, Bayesian Data Analysis. Third edit., 2014., Chapter 4, p. 84","code":""},{"path":"https://opensource.nibr.com/RBesT/articles/variances_MAP.html","id":"r-session-info","dir":"Articles","previous_headings":"Normal approximation of a logΓ\\log\\Gamma variate","what":"R Session Info","title":"Meta-Analytic-Predictive Priors for Variances","text":"","code":"sessionInfo() ## R version 4.4.2 (2024-10-31) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 24.04.1 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] bayesplot_1.11.1 purrr_1.0.2 dplyr_1.1.4 ggplot2_3.5.1 ## [5] knitr_1.49 RBesT_1.8-1 ## ## loaded via a namespace (and not attached): ## [1] tensorA_0.36.2.1 sass_0.4.9 generics_0.1.3 ## [4] stringi_1.8.4 digest_0.6.37 magrittr_2.0.3 ## [7] evaluate_1.0.3 grid_4.4.2 mvtnorm_1.3-3 ## [10] fastmap_1.2.0 plyr_1.8.9 jsonlite_1.8.9 ## [13] pkgbuild_1.4.6 backports_1.5.0 Formula_1.2-5 ## [16] gridExtra_2.3 QuickJSR_1.5.1 scales_1.3.0 ## [19] codetools_0.2-20 textshaping_0.4.1 jquerylib_0.1.4 ## [22] abind_1.4-8 cli_3.6.3 rlang_1.1.5 ## [25] munsell_0.5.1 withr_3.0.2 cachem_1.1.0 ## [28] yaml_2.3.10 StanHeaders_2.32.10 parallel_4.4.2 ## [31] tools_4.4.2 rstan_2.32.6 inline_0.3.21 ## [34] reshape2_1.4.4 rstantools_2.4.0 checkmate_2.3.2 ## [37] colorspace_2.1-1 assertthat_0.2.1 posterior_1.6.0 ## [40] vctrs_0.6.5 R6_2.5.1 matrixStats_1.5.0 ## [43] stats4_4.4.2 lifecycle_1.0.4 stringr_1.5.1 ## [46] fs_1.6.5 htmlwidgets_1.6.4 ragg_1.3.3 ## [49] pkgconfig_2.0.3 desc_1.4.3 pkgdown_2.1.1 ## [52] RcppParallel_5.1.9 pillar_1.10.1 bslib_0.8.0 ## [55] gtable_0.3.6 loo_2.8.0 glue_1.8.0 ## [58] Rcpp_1.0.14 systemfonts_1.2.0 xfun_0.50 ## [61] tibble_3.2.1 tidyselect_1.2.1 farver_2.1.2 ## [64] htmltools_0.5.8.1 labeling_0.4.3 rmarkdown_2.29 ## [67] compiler_4.4.2 distributional_0.5.0"},{"path":"https://opensource.nibr.com/RBesT/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Novartis Pharma AG. Copyright holder. Sebastian Weber. Author, maintainer. Beat Neuenschwander. Contributor. Heinz Schmidli. Contributor. Baldur Magnusson. Contributor. Yue Li. Contributor. Satrajit Roychoudhury. Contributor. Lukas . Widmer. Contributor. Trustees Columbia University. Copyright holder. R/stanmodels.R, configure, configure.win","code":""},{"path":"https://opensource.nibr.com/RBesT/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Weber S, Li Y, Seaman JW, Kakizume T, Schmidli H (2021). “Applying Meta-Analytic-Predictive Priors R Bayesian Evidence Synthesis Tools.” Journal Statistical Software, 100(19), 1–32. doi:10.18637/jss.v100.i19.","code":"@Article{, title = {Applying Meta-Analytic-Predictive Priors with the {R} {B}ayesian Evidence Synthesis Tools}, author = {Sebastian Weber and Yue Li and John W. Seaman and Tomoyuki Kakizume and Heinz Schmidli}, journal = {Journal of Statistical Software}, year = {2021}, volume = {100}, number = {19}, pages = {1--32}, doi = {10.18637/jss.v100.i19}, }"},{"path":"https://opensource.nibr.com/RBesT/index.html","id":"rbest-r-bayesian-evidence-synthesis-tools","dir":"","previous_headings":"","what":"R Bayesian Evidence Synthesis Tools","title":"R Bayesian Evidence Synthesis Tools","text":"Tool-set support Bayesian evidence synthesis. includes meta-analysis, (robust) prior derivation historical data, operating characteristics analysis (1 2 sample cases). Please refer Weber et al. (2021) details applying package Neuenschwander et al. (2010) Schmidli et al. (2014) explain details methodology.","code":""},{"path":"https://opensource.nibr.com/RBesT/index.html","id":"getting-started","dir":"","previous_headings":"","what":"Getting Started","title":"R Bayesian Evidence Synthesis Tools","text":"get quick overview package functionality, please refer introductory vignettes. recommend starting Getting started RBesT (binary) vignette first read.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":null,"dir":"Reference","previous_headings":"","what":"Ankylosing Spondylitis. — AS","title":"Ankylosing Spondylitis. — AS","text":"Data set containing historical information placebo phase II trial ankylosing spondylitis patients. primary efficacy endpoint percentage patients 20 according Assessment SpondyloArthritis international Society criteria improvement (ASAS20) week 6.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ankylosing Spondylitis. — AS","text":"","code":"AS"},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ankylosing Spondylitis. — AS","text":"data frame 8 rows 3 variables: study study n study size r number events","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Ankylosing Spondylitis. — AS","text":"Baeten D. et. al, Lancet, 2013, (382), 9906, p 1705","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/AS.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ankylosing Spondylitis. — AS","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) set.seed(34563) map_AS <- gMAP(cbind(r, n - r) ~ 1 | study, family = binomial, data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2 ) #> Assuming default prior location for beta: 0 #> Warning: The largest R-hat is 1.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Warning: Maximal Rhat > 1.1. Consider increasing RBesT.MC.warmup MCMC parameter. #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":null,"dir":"Reference","previous_headings":"","what":"Exact Confidence interval for Binary Proportion — BinaryExactCI","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"function calculates exact confidendence interval response rate presented \\(n\\) \\(r\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"","code":"BinaryExactCI(r, n, alpha = 0.05, drop = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"r Number success responder n Sample size alpha confidence level drop Determines drop called result","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"100 (1-\\(\\alpha\\))% exact confidence interval given response rate","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"Confidence intervals obtained procedure first given Clopper Pearson (1934). guarantees confidence level least (1-\\(\\alpha\\)). Details can found publication listed .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"Clopper, C. J. & Pearson, E. S. use confidence fiducial limits illustrated case binomial. Biometrika 1934.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/BinaryExactCI.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exact Confidence interval for Binary Proportion — BinaryExactCI","text":"","code":"BinaryExactCI(3, 20, 0.05) #> 2.5% 97.5% #> 0.03207094 0.37892683"},{"path":"https://opensource.nibr.com/RBesT/reference/Curry.html","id":null,"dir":"Reference","previous_headings":"","what":"Functional programming utilities — Curry","title":"Functional programming utilities — Curry","text":"function functional","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/Curry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Functional programming utilities — Curry","text":"","code":"Curry(FUN, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":null,"dir":"Reference","previous_headings":"","what":"R Bayesian Evidence Synthesis Tools — RBesT-package","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"RBesT tools designed support derivation parametric informative priors, asses design characeristics perform analyses. Supported endpoints include normal, binary Poisson.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"introductory material, please refer vignettes include Introduction (binary) Introduction (normal) Customizing RBesT Plots Robust MAP, advanced usage main function package gMAP. See help page detailed description statistical model.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"version-history","dir":"Reference","previous_headings":"","what":"Version History","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"See NEWS.md file.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"Stan Development Team (2020). RStan: R interface Stan. R package version 2.19.3. https://mc-stan.org","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/RBesT-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"R Bayesian Evidence Synthesis Tools — RBesT-package","text":"Maintainer: Sebastian Weber sebastian.weber@novartis.com contributors: Novartis Pharma AG [copyright holder] Beat Neuenschwander beat.neuenschwander@novartis.com [contributor] Heinz Schmidli heinz.schmidli@novartis.com [contributor] Baldur Magnusson baldur.magnusson@novartis.com [contributor] Yue Li yue-1.li@novartis.com [contributor] Satrajit Roychoudhury satrajit.roychoudhury@novartis.com [contributor] Lukas . Widmer lukas_andreas.widmer@novartis.com (ORCID) [contributor] Trustees Columbia University (R/stanmodels.R, configure, configure.win) [copyright holder]","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize Arrays — SimSum","title":"Summarize Arrays — SimSum","text":"function calculates summary statistics arbitrary arrays.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize Arrays — SimSum","text":"","code":"SimSum( x, min.max = FALSE, n.sim = FALSE, probs = c(0.025, 0.5, 0.975), margin = ifelse(is.null(dim(x) | length(dim(x)) == 1), 2, length(dim(x))) )"},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarize Arrays — SimSum","text":"x Object summarize can numerical vector, matrix multi-dimensional array min.max Enables include minimum maximum output. n.sim Enables include number observations output. probs Quantiles output. margin Margin input array summary function applied.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/SimSum.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Summarize Arrays — SimSum","text":"function calculates default mean, standard deviation specified qantiles default median 95 mulit-dimensional array specified x, function default calculate summaries margin largest dimension. case vector matrix, function transpose results better readabiliy.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":null,"dir":"Reference","previous_headings":"","what":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"Fitting series mixtures conjugate distributions sample, using Expectation-Maximization (EM). number mixture components specified vector Nc. First Nc[1] component mixture fitted, Nc[2] component mixture, . mixture providing best AIC value selected.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"","code":"automixfit(sample, Nc = seq(1, 4), k = 6, thresh = -Inf, verbose = FALSE, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"sample Sample fitted mixture distribution. Nc Vector mixture components try (default seq(1,4)). k Penalty parameter AIC calculation (default 6) thresh procedure stops difference subsequent AIC values smaller threshold (default -Inf). Setting threshold 0 stops automixfit AIC becomes worse. verbose Enable verbose logging. ... arguments passed mixfit, including type.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"result best fitting mixture model returned, .e. model lowest AIC. models saved attribute models.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"type argument specifies distribution mixture components, can normal, beta gamma distribution. penalty parameter k 2 standard AIC definition. Collet (2003) suggested use values range 2 6, larger values k penalize complex models. favor mixtures fewer components value 6 used default.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"Collet D. Modeling Survival Data Medical Research. 2003; Chapman Hall/CRC.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/automixfit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Automatic Fitting of Mixtures of Conjugate Distributions to a Sample — automixfit","text":"","code":"# random sample of size 1000 from a mixture of 2 beta components bm <- mixbeta(beta1 = c(0.4, 20, 90), beta2 = c(0.6, 35, 65)) bmSamp <- rmix(bm, 1000) # fit with EM mixture models with up to 10 components and stop if # AIC increases bmFit <- automixfit(bmSamp, Nc = 1:10, thresh = 0, type = \"beta\") bmFit #> EM for Beta Mixture Model #> Log-Likelihood = 1099.367 #> #> Univariate beta mixture #> Mixture Components: #> comp1 comp2 #> w 0.586131 0.413869 #> a 33.422658 18.251968 #> b 61.784396 82.825370 # advanced usage: find out about all discarded models bmFitAll <- attr(bmFit, \"models\") sapply(bmFitAll, AIC, k = 6) #> 2 3 1 #> -2168.735 -2150.802 -1871.069"},{"path":"https://opensource.nibr.com/RBesT/reference/chains2sample.html","id":null,"dir":"Reference","previous_headings":"","what":"Scrambles the order of a mcmc array object for usage as a mcmc sample. It is advisable to set order once per mcmc run, otherwise correlations in the mcmc sample will be lost. — chains2sample","title":"Scrambles the order of a mcmc array object for usage as a mcmc sample. It is advisable to set order once per mcmc run, otherwise correlations in the mcmc sample will be lost. — chains2sample","text":"Scrambles order mcmc array object usage mcmc sample. advisable set order per mcmc run, otherwise correlations mcmc sample lost.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/chains2sample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Scrambles the order of a mcmc array object for usage as a mcmc sample. It is advisable to set order once per mcmc run, otherwise correlations in the mcmc sample will be lost. — chains2sample","text":"","code":"chains2sample(chains, order, drop = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/colVars.html","id":null,"dir":"Reference","previous_headings":"","what":"Fast column-wise calculation of unbiased variances — colVars","title":"Fast column-wise calculation of unbiased variances — colVars","text":"Fast column-wise calculation unbiased variances","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/colVars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fast column-wise calculation of unbiased variances — colVars","text":"","code":"colVars(a)"},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":null,"dir":"Reference","previous_headings":"","what":"Ulcerative Colitis. — colitis","title":"Ulcerative Colitis. — colitis","text":"Data set containing historical information placebo arm phase II proof--concept trial treatment ulcerative colitis. primary outcome remission week 8 (binary).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ulcerative Colitis. — colitis","text":"","code":"colitis"},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Ulcerative Colitis. — colitis","text":"data frame 4 rows 3 variables: study study n study size r number events","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/colitis.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Ulcerative Colitis. — colitis","text":"Neuenschwander B, Capkun-Niggli G, Branson M, Spiegelhalter DJ. Summarizing historical information controls clinical trials. Clin Trials. 2010; 7(1):5-18","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":null,"dir":"Reference","previous_headings":"","what":"Crohn's disease. — crohn","title":"Crohn's disease. — crohn","text":"Data set containing historical information placebo arm relevant studies treatment Crohn's disease. primary outcome change baseline Crohn's Disease Activity Index (CDAI) duration 6 weeks. Standard deviation change baseline endpoint approximately 88.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Crohn's disease. — crohn","text":"","code":"crohn"},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Crohn's disease. — crohn","text":"data frame 4 rows 3 variables: study study n study size y mean CDAI change","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Crohn's disease. — crohn","text":"Hueber W. et. al, Gut, 2012, 61(12):1693-1700","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/crohn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Crohn's disease. — crohn","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) set.seed(546346) map_crohn <- gMAP(cbind(y, y.se) ~ 1 | study, family = gaussian, data = transform(crohn, y.se = 88 / sqrt(n)), weights = n, tau.dist = \"HalfNormal\", tau.prior = 44, beta.prior = cbind(0, 88) ) #> Warning: The largest R-hat is 1.09, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":null,"dir":"Reference","previous_headings":"","what":"Beta-Binomial Probabilities — dBetaBinomial","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"Beta-Binomial Probabilities","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"","code":"dBetaBinomial(r, n, a, b, log = FALSE)"},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"r, n number successes (responders) n , b parameters Beta distribution response probability","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/dBetaBinomial.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Beta-Binomial Probabilities — dBetaBinomial","text":"r,n,,b can scalar vectors. vectors used, must length","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Function for 1 Sample Designs — decision1S","title":"Decision Function for 1 Sample Designs — decision1S","text":"function sets 1 sample one-sided decision function arbitrary number conditions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Function for 1 Sample Designs — decision1S","text":"","code":"decision1S(pc = 0.975, qc = 0, lower.tail = TRUE) oc1Sdecision(pc = 0.975, qc = 0, lower.tail = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Function for 1 Sample Designs — decision1S","text":"pc Vector critical cumulative probabilities. qc Vector respective critical values. Must match length pc. lower.tail Logical; TRUE (default), probabilities \\(P(X \\leq x)\\), otherwise, \\(P(X > x)\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Function for 1 Sample Designs — decision1S","text":"function returns decision function takes two arguments. first argument expected mixture (posterior) distribution tested specified conditions met. logical second argument determines function acts indicator function function returns distance decision boundary condition log-space, .e. distance 0 decision boundary, negative 0 decision positive 1 decision.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Function for 1 Sample Designs — decision1S","text":"function creates one-sided decision function takes two arguments. first argument expected mixture (posterior) distribution. distribution tested whether fulfills required threshold conditions specified pc qc arguments returns 1 conditions met 0 otherwise. Hence, lower.tail=TRUE condition \\(\\) equivalent $$P(\\theta \\leq q_{c,}) > p_{c,}$$ decision function implemented indicator function basis heavy-side step function \\(H(x)\\) \\(0\\) \\(x \\leq 0\\) \\(1\\) \\(x > 0\\). conditions must met, final indicator function returns $$\\Pi_i H_i(P(\\theta \\leq q_{c,}) - p_{c,} ).$$ second argument set TRUE distance metric returned component-wise per defined condition $$ D_i = \\log(P(\\theta < q_{c,})) - \\log(p_{c,}) .$$ indicator functions can used input 1-sample boundary, OC PoS calculations using oc1S pos1S .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Decision Function for 1 Sample Designs — decision1S","text":"oc1Sdecision(): Deprecated old function name. Please use decision1S instead.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Decision Function for 1 Sample Designs — decision1S","text":"Neuenschwander B, Rouyrre N, Hollaender H, Zuber E, Branson M. proof concept phase II non-inferiority criterion. Stat. Med.. 2011, 30:1618-1627","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Function for 1 Sample Designs — decision1S","text":"","code":"# see Neuenschwander et al., 2011 # example is for a time-to-event trial evaluating non-inferiority # using a normal approximation for the log-hazard ratio # reference scale s <- 2 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) # n for which design was intended nL <- 233 c1 <- theta_ni - za * s / sqrt(n1) # flat prior flat_prior <- mixnorm(c(1, 0, 100), sigma = s) # standard NI design decA <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # for double criterion with indecision point (mean estimate must be # lower than this) theta_c <- c1 # double criterion design # statistical significance (like NI design) dec1 <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # require mean to be at least as good as theta_c dec2 <- decision1S(0.5, theta_c, lower.tail = TRUE) # combination decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) theta_eval <- c(theta_a, theta_c, theta_ni) # we can display the decision function definition decComb #> 1 sample decision function #> Conditions for acceptance: #> P(theta <= 0.4) > 0.95 #> P(theta <= 0.13576435472344) > 0.5 # and use it to decide if a given distribution fulfills all # criterions defined # for the prior decComb(flat_prior) #> [1] 0 # or for a possible outcome of the trial # here with HR of 0.8 for 40 events decComb(postmix(flat_prior, m = log(0.8), n = 40)) #> Using default prior reference scale 2 #> [1] 1"},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Boundary for 1 Sample Designs — decision1S_boundary","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"Calculates decision boundary 1 sample design. critical value decision function change 0 (failure) 1 (success).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"","code":"decision1S_boundary(prior, n, decision, ...) # S3 method for class 'betaMix' decision1S_boundary(prior, n, decision, ...) # S3 method for class 'normMix' decision1S_boundary(prior, n, decision, sigma, eps = 1e-06, ...) # S3 method for class 'gammaMix' decision1S_boundary(prior, n, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"prior Prior analysis. n Sample size experiment. decision One-sample decision function use; see decision1S. ... Optional arguments. sigma fixed reference scale. left unspecified, default reference scale prior assumed. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"Returns critical value \\(y_c\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"specification 1 sample design (prior, sample size decision function, \\(D(y)\\)), uniquely defines decision boundary $$y_c = \\max_y\\{D(y) = 1\\},$$ maximal value \\(y\\) whenever decision \\(D(y)\\) function changes value 1 0 decision function lower.tail=TRUE (otherwise definition \\(y_c = \\max_{y}\\{D(y) = 0\\}\\)). decision function may change single critical value one-sided decision functions supported. , \\(y\\) defined binary Poisson endpoints sufficient statistic \\(y = \\sum_{=1}^{n} y_i\\) normal case mean \\(\\bar{y} = 1/n \\sum_{=1}^n y_i\\). convention critical value \\(y_c\\) depends whether left (lower.tail=TRUE) right-sided decision function (lower.tail=FALSE) used. lower.tail=TRUE critical value \\(y_c\\) largest value decision 1, \\(D(y \\leq y_c) = 1\\), lower.tail=FALSE \\(D(y > y_c) = 1\\) holds. aligned cumulative density function definition within R (see example pbinom).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"decision1S_boundary(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. decision1S_boundary(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture prior mean. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function decision1S_boundary extra argument eps (defaults \\(10^{-6}\\)). critical value \\(y_c\\) searched region probability mass 1-eps \\(y\\). decision1S_boundary(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function decision1S_boundary takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision1S_boundary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Boundary for 1 Sample Designs — decision1S_boundary","text":"","code":"# non-inferiority example using normal approximation of log-hazard # ratio, see ?decision1S for all details s <- 2 flat_prior <- mixnorm(c(1, 0, 100), sigma = s) nL <- 233 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) theta_c <- theta_ni - za * s / sqrt(n1) # double criterion design # statistical significance (like NI design) dec1 <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # require mean to be at least as good as theta_c dec2 <- decision1S(0.5, theta_c, lower.tail = TRUE) # combination decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) # critical value of double criterion design decision1S_boundary(flat_prior, nL, decComb) #> Using default prior reference scale 2 #> [1] 0.1357511 # ... is limited by the statistical significance ... decision1S_boundary(flat_prior, nL, dec1) #> Using default prior reference scale 2 #> [1] 0.1844494 # ... or the indecision point (whatever is smaller) decision1S_boundary(flat_prior, nL, dec2) #> Using default prior reference scale 2 #> [1] 0.1357511"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Function for 2 Sample Designs — decision2S","title":"Decision Function for 2 Sample Designs — decision2S","text":"function sets 2 sample one-sided decision function arbitrary number conditions difference distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Function for 2 Sample Designs — decision2S","text":"","code":"decision2S( pc = 0.975, qc = 0, lower.tail = TRUE, link = c(\"identity\", \"logit\", \"log\") ) oc2Sdecision( pc = 0.975, qc = 0, lower.tail = TRUE, link = c(\"identity\", \"logit\", \"log\") )"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Function for 2 Sample Designs — decision2S","text":"pc Vector critical cumulative probabilities difference distribution. qc Vector respective critical values difference distribution. Must match length pc. lower.tail Logical; TRUE (default), probabilities \\(P(X \\leq x)\\), otherwise, \\(P(X > x)\\). link Enables application link function prior evaluating difference distribution. Can take one values identity (default), logit log.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Function for 2 Sample Designs — decision2S","text":"function returns decision function takes three arguments. first second argument expected mixture (posterior) distributions difference distribution formed conditions tested. third argument determines function acts indicator function function returns distance decision boundary condition log-space. , distance 0 decision boundary, negative 0 decision positive 1 decision.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Function for 2 Sample Designs — decision2S","text":"function creates one-sided decision function basis difference distribution 2 sample situation. support double criterion designs, see Neuenschwander et al., 2010, arbitrary number criterions can given. decision function demands probability mass critical value qc difference \\(\\theta_1 - \\theta_2\\) least pc. Hence, lower.tail=TRUE condition \\(\\) equivalent $$P(\\theta_1 - \\theta_2 \\leq q_{c,}) > p_{c,}$$ decision function implemented indicator function using heavy-side step function \\(H(x)\\) \\(0\\) \\(x \\leq 0\\) \\(1\\) \\(x > 0\\). conditions must met, final indicator function returns $$\\Pi_i H_i(P(\\theta_1 - \\theta_2 \\leq q_{c,}) - p_{c,} ),$$ \\(1\\) conditions met \\(0\\) otherwise. lower.tail=FALSE differences must greater given quantiles qc. Note whenever link identity requested, underlying densities first transformed using link function probabilties differences calculated transformed space. Hence, binary endpoint default identity link calculate risk differences, logit link lead decisions based differences logits corresponding criterion based log-odds. log link evaluate ratios instead absolute differences useful binary endpoint counting rates. respective critical quantiles qc must given transformed scale.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Decision Function for 2 Sample Designs — decision2S","text":"oc2Sdecision(): Deprecated old function name. Please use decision2S instead.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Decision Function for 2 Sample Designs — decision2S","text":"Gsponer T, Gerber F, Bornkamp B, Ohlssen D, Vandemeulebroecke M, Schmidli H.practical guide Bayesian group sequential designs. Pharm. Stat.. 2014; 13: 71-80","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Function for 2 Sample Designs — decision2S","text":"","code":"# see Gsponer et al., 2010 priorT <- mixnorm(c(1, 0, 0.001), sigma = 88, param = \"mn\") priorP <- mixnorm(c(1, -49, 20), sigma = 88, param = \"mn\") # the success criteria is for delta which are larger than some # threshold value which is why we set lower.tail=FALSE successCrit <- decision2S(c(0.95, 0.5), c(0, 50), FALSE) # the futility criterion acts in the opposite direction futilityCrit <- decision2S(c(0.90), c(40), TRUE) print(successCrit) #> 2 sample decision function #> Conditions for acceptance: #> P(theta1 - theta2 > 0) > 0.95 #> P(theta1 - theta2 > 50) > 0.5 #> Link: identity print(futilityCrit) #> 2 sample decision function #> Conditions for acceptance: #> P(theta1 - theta2 <= 40) > 0.9 #> Link: identity # consider decision for specific outcomes postP_interim <- postmix(priorP, n = 10, m = -50) #> Using default prior reference scale 88 postT_interim <- postmix(priorT, n = 20, m = -80) #> Using default prior reference scale 88 futilityCrit(postP_interim, postT_interim) #> [1] 0 successCrit(postP_interim, postT_interim) #> [1] 0 # Binary endpoint with double criterion decision on log-odds scale # 95% certain positive difference and an odds ratio of 2 at least decL2 <- decision2S(c(0.95, 0.5), c(0, log(2)), lower.tail = FALSE, link = \"logit\") # 95% certain positive difference and an odds ratio of 3 at least decL3 <- decision2S(c(0.95, 0.5), c(0, log(3)), lower.tail = FALSE, link = \"logit\") # data scenario post1 <- postmix(mixbeta(c(1, 1, 1)), n = 40, r = 10) post2 <- postmix(mixbeta(c(1, 1, 1)), n = 40, r = 18) # positive outcome and a median odds ratio of at least 2 ... decL2(post2, post1) #> [1] 1 # ... but not more than 3 decL3(post2, post1) #> [1] 0"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":null,"dir":"Reference","previous_headings":"","what":"Decision Boundary for 2 Sample Designs — decision2S_boundary","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"decision2S_boundary function defines 2 sample design (priors, sample sizes, decision function) calculation decision boundary. function returned calculates critical value first sample \\(y_{1,c}\\) function outcome second sample \\(y_2\\). decision boundary, decision function change 0 (failure) 1 (success) respective outcomes.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"","code":"decision2S_boundary(prior1, prior2, n1, n2, decision, ...) # S3 method for class 'betaMix' decision2S_boundary(prior1, prior2, n1, n2, decision, eps, ...) # S3 method for class 'normMix' decision2S_boundary( prior1, prior2, n1, n2, decision, sigma1, sigma2, eps = 1e-06, Ngrid = 10, ... ) # S3 method for class 'gammaMix' decision2S_boundary(prior1, prior2, n1, n2, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"prior1 Prior sample 1. prior2 Prior sample 2. n1, n2 Sample size respective samples. Sample size n1 must greater 0 sample size n2 must greater equal 0. decision Two-sample decision function use; see decision2S. ... Optional arguments. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\). sigma1 fixed reference scale sample 1. left unspecified, default reference scale prior 1 assumed. sigma2 fixed reference scale sample 2. left unspecified, default reference scale prior 2 assumed. Ngrid Determines density discretization grid decision function evaluated (see details).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"Returns function single argument. function calculates dependence outcome \\(y_2\\) sample 2 critical value \\(y_{1,c}\\) defined design change decision 0 1 (vice versa, depending decision function).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"2 sample design specification priors, sample sizes decision function, \\(D(y_1,y_2)\\), uniquely defines decision boundary $$D_1(y_2) = \\max_{y_1}\\{D(y_1,y_2) = 1\\},$$ critical value \\(y_{1,c}\\) conditional value \\(y_2\\) whenever decision \\(D(y_1,y_2)\\) function changes value 0 1 decision function lower.tail=TRUE (otherwise definition \\(D_1(y_2) = \\max_{y_1}\\{D(y_1,y_2) = 0\\}\\)). decision function may change single critical value given \\(y_{2}\\) one-sided decision functions supported. , \\(y_2\\) defined binary Poisson endpoints sufficient statistic \\(y_2 = \\sum_{=1}^{n_2} y_{2,}\\) normal case mean \\(\\bar{y}_2 = 1/n_2 \\sum_{=1}^{n_2} y_{2,}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"decision2S_boundary(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. optional argument eps defined, approximate method used limits search decision boundary region 1-eps probability mass. useful designs large sample sizes exact approach costly calculate. decision2S_boundary(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture priors means. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function two extra arguments (defaults): eps (\\(10^{-6}\\)) Ngrid (10). decision boundary searched region probability mass 1-eps, respectively \\(y_1\\) \\(y_2\\). continuous decision function evaluated discrete grid, determined spacing \\(\\delta_2 = \\sigma_2/\\sqrt{N_{grid}}\\). decision boundary evaluated discrete steps, spline used inter-polate decision boundary intermediate points. decision2S_boundary(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function decision2S_boundary takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y_1\\) \\(y_2\\), respectively.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/decision2S_boundary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Decision Boundary for 2 Sample Designs — decision2S_boundary","text":"","code":"# see ?decision2S for details of example priorT <- mixnorm(c(1, 0, 0.001), sigma = 88, param = \"mn\") priorP <- mixnorm(c(1, -49, 20), sigma = 88, param = \"mn\") # the success criteria is for delta which are larger than some # threshold value which is why we set lower.tail=FALSE successCrit <- decision2S(c(0.95, 0.5), c(0, 50), FALSE) # the futility criterion acts in the opposite direction futilityCrit <- decision2S(c(0.90), c(40), TRUE) # success criterion boundary successBoundary <- decision2S_boundary(priorP, priorT, 10, 20, successCrit) #> Using default prior 1 reference scale 88 #> Using default prior 2 reference scale 88 # futility criterion boundary futilityBoundary <- decision2S_boundary(priorP, priorT, 10, 20, futilityCrit) #> Using default prior 1 reference scale 88 #> Using default prior 2 reference scale 88 curve(successBoundary(x), -25:25 - 49, xlab = \"y2\", ylab = \"critical y1\") curve(futilityBoundary(x), lty = 2, add = TRUE) # hence, for mean in sample 2 of 10, the critical value for y1 is y1c <- futilityBoundary(-10) # around the critical value the decision for futility changes futilityCrit(postmix(priorP, m = y1c + 1E-3, n = 10), postmix(priorT, m = -10, n = 20)) #> Using default prior reference scale 88 #> Using default prior reference scale 88 #> [1] 0 futilityCrit(postmix(priorP, m = y1c - 1E-3, n = 10), postmix(priorT, m = -10, n = 20)) #> Using default prior reference scale 88 #> Using default prior reference scale 88 #> [1] 1"},{"path":"https://opensource.nibr.com/RBesT/reference/dlink-set.html","id":null,"dir":"Reference","previous_headings":"","what":"Transform Densities with a link function — dlink<-","title":"Transform Densities with a link function — dlink<-","text":"One--one transforms (mixture) densities using link function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/dlink-set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transform Densities with a link function — dlink<-","text":"","code":"dlink(object) <- value"},{"path":"https://opensource.nibr.com/RBesT/reference/dlink-set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Transform Densities with a link function — dlink<-","text":"object Mixture density apply link . value Link. Note: link functions assumed order preserving, .e. x_1 < x_2 holds, link(x_1) < link(x_2).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":null,"dir":"Reference","previous_headings":"","what":"Effective Sample Size for a Conjugate Prior — ess","title":"Effective Sample Size for a Conjugate Prior — ess","text":"Calculates Effective Sample Size (ESS) mixture prior. ESS indicates many experimental units prior roughly equivalent .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Effective Sample Size for a Conjugate Prior — ess","text":"","code":"ess(mix, method = c(\"elir\", \"moment\", \"morita\"), ...) # S3 method for class 'betaMix' ess(mix, method = c(\"elir\", \"moment\", \"morita\"), ..., s = 100) # S3 method for class 'gammaMix' ess(mix, method = c(\"elir\", \"moment\", \"morita\"), ..., s = 100, eps = 1e-04) # S3 method for class 'normMix' ess( mix, method = c(\"elir\", \"moment\", \"morita\"), ..., family = gaussian, sigma, s = 100 )"},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Effective Sample Size for a Conjugate Prior — ess","text":"mix Prior (mixture conjugate distributions). method Selects used method. Can either elir (default), moment morita. ... Optional arguments applicable specific methods. s morita method large constant ensure prior scaled value vague (default 100); see Morita et al. (2008) details. eps Probability mass left numerical integration expected information Poisson-Gamma case Morita method (defaults 1E-4). family defines data likelihood link function (binomial, gaussian, poisson). sigma reference scale.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Effective Sample Size for a Conjugate Prior — ess","text":"Returns ESS prior floating point number.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Effective Sample Size for a Conjugate Prior — ess","text":"ESS calculated using either expected local information ratio (elir) Neuenschwander et al. (2020), moments approach method Morita et al. (2008). elir approach measures effective sample size terms average curvature prior relation Fisher information. Informally corresponds average peakiness prior relation information content single observation. elir approach ESS fulfills predictive consistency. predictive consistency ESS requires ESS prior consistent considering averaged posterior ESS additional data distributed according predictive distribution prior. expectation posterior ESS taken wrt prior predictive distribution averaged posterior ESS corresponds sum prior ESS number forward simulated data items. elir approach results ESS estimates neither conservative liberal whereas moments method yields conservative morita method liberal results. See example section demonstration predictive consistency. moments method mean standard deviation mixture calculated approximated conjugate distribution mean standard deviation. conjugate distributions, ESS well defined. See examples step-wise calculation beta mixture case. Morita method used evaluates mixture prior mode instead mean proposed originally Morita. method may lead optimistic ESS values, especially mixture contains many components. calculation Morita approach follows approach presented Neuenschwander B. et (2019) avoids need minimization restrict ESS integer. arguments sigma family specific normal mixture densities. specify sampling standard deviation gaussian family (default) also allowing consider ESS standard one-parameter exponential families, .e. binomial poisson. function supports non-gaussian families unit dispersion .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Effective Sample Size for a Conjugate Prior — ess","text":"ess(betaMix): ESS beta mixtures. ess(gammaMix): ESS gamma mixtures. ess(normMix): ESS normal mixtures.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Effective Sample Size for a Conjugate Prior — ess","text":"Morita S, Thall PF, Mueller P. Determining effective sample size parametric prior. Biometrics 2008;64(2):595-602. Neuenschwander B., Weber S., Schmidli H., O’Hagan . (2020). Predictively consistent prior effective sample sizes. Biometrics, 76(2), 578–587. https://doi.org/10.1111/biom.13252","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/ess.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Effective Sample Size for a Conjugate Prior — ess","text":"","code":"# Conjugate Beta example a <- 5 b <- 15 prior <- mixbeta(c(1, a, b)) ess(prior) #> [1] 20 (a + b) #> [1] 20 # Beta mixture example bmix <- mixbeta(rob = c(0.2, 1, 1), inf = c(0.8, 10, 2)) ess(bmix, \"elir\") #> [1] 7.65152 ess(bmix, \"moment\") #> [1] 3.161034 # moments method is equivalent to # first calculate moments bmix_sum <- summary(bmix) # then calculate a and b of a matching beta ab_matched <- ms2beta(bmix_sum[\"mean\"], bmix_sum[\"sd\"]) # finally take the sum of a and b which are equivalent # to number of responders/non-responders respectivley round(sum(ab_matched)) #> [1] 3 ess(bmix, method = \"morita\") #> [1] 8.487603 # One may also calculate the ESS on the logit scale, which # gives slightly different results due to the parameter # transformation, e.g.: prior_logit <- mixnorm(c(1, log(5 / 15), sqrt(1 / 5 + 1 / 15))) ess(prior_logit, family = binomial) #> [1] 21.78289 bmix_logit <- mixnorm(rob = c(0.2, 0, 2), inf = c(0.8, log(10 / 2), sqrt(1 / 10 + 1 / 2))) ess(bmix_logit, family = binomial) #> [1] 10.12276 # Predictive consistency of elir n_forward <- 1E1 bmixPred <- preddist(bmix, n = n_forward) pred_samp <- rmix(bmixPred, 1E2) # use more samples here for greater accuracy, e.g. # pred_samp <- rmix(bmixPred, 1E3) pred_ess <- sapply(pred_samp, function(r) ess(postmix(bmix, r = r, n = n_forward), \"elir\")) ess(bmix, \"elir\") #> [1] 7.65152 mean(pred_ess) - n_forward #> [1] 7.071933 # Normal mixture example nmix <- mixnorm(rob = c(0.5, 0, 2), inf = c(0.5, 3, 4), sigma = 10) ess(nmix, \"elir\") #> Using default prior reference scale 10 #> [1] 10.82796 ess(nmix, \"moment\") #> Using default prior reference scale 10 #> [1] 8.163265 # the reference scale determines the ESS sigma(nmix) <- 20 ess(nmix) #> Using default prior reference scale 20 #> [1] 43.31185 # we may also interpret normal mixtures as densities assigned to # parameters of a logit transformed response rate of a binomial nmix_logit <- mixnorm(c(1, logit(1 / 4), 2 / sqrt(10))) ess(nmix_logit, family = binomial) #> [1] 15.17836 # Gamma mixture example gmix <- mixgamma(rob = c(0.3, 20, 4), inf = c(0.7, 50, 10)) ess(gmix) ## interpreted as appropriate for a Poisson likelihood (default) #> [1] 7.159378 likelihood(gmix) <- \"exp\" ess(gmix) ## interpreted as appropriate for an exponential likelihood #> [1] 34.93388"},{"path":"https://opensource.nibr.com/RBesT/reference/fill.html","id":null,"dir":"Reference","previous_headings":"","what":"Fill numeric objects — fill","title":"Fill numeric objects — fill","text":"Returns numeric input object value given respects dimensionalty type input.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/fill.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fill numeric objects — fill","text":"","code":"fill(x, value)"},{"path":"https://opensource.nibr.com/RBesT/reference/fill.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fill numeric objects — fill","text":"x Input numeric object. value Value filled.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":null,"dir":"Reference","previous_headings":"","what":"Forest Plot — forest_plot","title":"Forest Plot — forest_plot","text":"Creates forest plot gMAP analysis objects.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Forest Plot — forest_plot","text":"","code":"forest_plot( x, prob = 0.95, est = c(\"both\", \"MAP\", \"Mean\", \"none\"), model = c(\"stratified\", \"both\", \"meta\"), point_est = c(\"median\", \"mean\"), size = 1.25, alpha = 0.5 )"},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Forest Plot — forest_plot","text":"x gMAP object. prob confidence interval width probability mass credible intervals. est can set one (default), MAP, Mean none. Controls model estimates included. model controls estimates displayed per study. Either stratified (default), meta. point_est shown point estimate. Either median (default) mean. size controls point linesize. alpha transparency reference line. Setting alpha=0 suppresses reference line.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Forest Plot — forest_plot","text":"function returns ggplot2 plot object.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Forest Plot — forest_plot","text":"function creates forest plot suitable gMAP analyses. Note Meta-Analytic-Predictive prior included default plot opposed showing estimated model mean. See examples obtain standard forest plots. Also note plot internally flips x y-axis. Therefore, want manipulate x-axis, give commands affecting y-axis (see examples).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Forest Plot — forest_plot","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/forest_plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Forest Plot — forest_plot","text":"","code":"# we consider the example AS MAP analysis example(AS) #> #> AS> ## Setting up dummy sampling for fast execution of example #> AS> ## Please use 4 chains and 20x more warmup & iter in practice #> AS> .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, #> AS+ RBesT.MC.chains=2, RBesT.MC.thin=1) #> #> AS> set.seed(34563) #> #> AS> map_AS <- gMAP(cbind(r, n - r) ~ 1 | study, #> AS+ family = binomial, #> AS+ data = AS, #> AS+ tau.dist = \"HalfNormal\", tau.prior = 1, #> AS+ beta.prior = 2 #> AS+ ) #> Assuming default prior location for beta: 0 #> Warning: The largest R-hat is 1.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Warning: Maximal Rhat > 1.1. Consider increasing RBesT.MC.warmup MCMC parameter. #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. #> #> AS> ## Recover user set sampling defaults #> AS> options(.user_mc_options) # default forest plot for a gMAP analysis forest_plot(map_AS) # standard forest plot (only stratified estimate and Mean) forest_plot(map_AS, est = c(\"Mean\"), model = \"stratified\") # to further customize these plots, first load bayesplot and ggplot2 library(bayesplot) #> This is bayesplot version 1.11.1 #> - Online documentation and vignettes at mc-stan.org/bayesplot #> - bayesplot theme set to bayesplot::theme_default() #> * Does _not_ affect other ggplot2 plots #> * See ?bayesplot_theme_set for details on theme setting library(ggplot2) # to make plots with red colors, big fonts for presentations, suppress # the x axis label and add another title (with a subtitle) color_scheme_set(\"red\") theme_set(theme_default(base_size = 16)) forest_plot(map_AS, size = 2) + yaxis_title(FALSE) + ggtitle(\"Ankylosing Spondylitis Forest Plot\", subtitle = \"Control Group Response Rate\" ) # the defaults are set with color_scheme_set(\"blue\") theme_set(theme_default(base_size = 12))"},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":null,"dir":"Reference","previous_headings":"","what":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"Meta-Analytic-Predictive (MAP) analysis generalized linear models suitable normal, binary, Poisson data. Model specification overall syntax follows mainly glm conventions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"","code":"gMAP( formula, family = gaussian, data, weights, offset, tau.strata, tau.dist = c(\"HalfNormal\", \"TruncNormal\", \"Uniform\", \"Gamma\", \"InvGamma\", \"LogNormal\", \"TruncCauchy\", \"Exp\", \"Fixed\"), tau.prior, tau.strata.pred = 1, beta.prior, prior_PD = FALSE, REdist = c(\"normal\", \"t\"), t.df = 5, contrasts = NULL, iter = getOption(\"RBesT.MC.iter\", 6000), warmup = getOption(\"RBesT.MC.warmup\", 2000), thin = getOption(\"RBesT.MC.thin\", 4), init = getOption(\"RBesT.MC.init\", 1), chains = getOption(\"RBesT.MC.chains\", 4), cores = getOption(\"mc.cores\", 1L) ) # S3 method for class 'gMAP' print(x, digits = 3, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gMAP' fitted(object, type = c(\"response\", \"link\"), probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gMAP' coef(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gMAP' as.matrix(x, ...) # S3 method for class 'gMAP' summary( object, type = c(\"response\", \"link\"), probs = c(0.025, 0.5, 0.975), ... )"},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"formula model formula describing linear predictor encoding grouping; see details family defines data likelihood link function (binomial, gaussian, poisson) data optional data frame containing variables model. found data, variables taken environment(formula). weights optional weight vector; see details . offset offset term statistical model used Poisson data tau.strata sets exchangability stratum per study. , expected study belongs single stratum. Default assign studies stratum 1. See section differential heterogeniety . tau.dist type prior distribution tau; supported priors HalfNormal (default), TruncNormal, Uniform, Gamma, InvGamma, LogNormal, TruncCauchy, Exp Fixed. tau.prior parameters prior distribution tau; see section prior specification . tau.strata.pred index prediction stratum; default 1. beta.prior mean standard deviation normal priors regression coefficients, see section prior specification . prior_PD logical indicate prior predictive distribution sampled (conditioning data). Defaults FALSE. REdist type random effects distribution. Normal (default) t. t.df degrees freedom random-effects distribution t. contrasts optional list; See contrasts.arg model.matrix.default. iter number iterations (including warmup). warmup number warmup iterations. thin period saving samples. init positive number specify uniform range unconstrained space random initialization. See stan. chains number Markov chains. cores number cores parallel sampling chains. x, object gMAP analysis object created gMAP function digits number displayed significant digits. probs defines quantiles reported. ... optional arguments ignored type sets reported scale (response (default) link).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"function returns S3 object type gMAP. See methods section applicable functions query object.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"meta-analytic-predictive (MAP) approach derives prior historical data using hierarchical model. statistical model formulated generalized linear mixed model binary, normal (fixed \\(\\sigma\\)) Poisson endpoints: $$y_{ih}|\\theta_{ih} \\sim f(y_{ih} | \\theta_{ih})$$ , \\(=1,\\ldots,N\\) index observations, \\(h=1,\\ldots,H\\) index grouping (usually studies). model assumes linear predictor transformed mean $$g(\\theta_{ih}; x_{ih},\\beta) = x_{ih} \\, \\beta + \\epsilon_h$$ \\(x_{ih}\\) row vector \\(k\\) covariates observation \\(\\). variance component assumed default normal $$\\epsilon_h \\sim N(0,\\tau^2), \\qquad h=1,\\ldots,H$$ Lastly, Bayesian implementation assumes independent normal priors \\(k\\) regression coefficients prior -group standard deviation \\(\\tau\\) (see taud.dist available distributions). MAP prior derived model conditional distribution \\(\\theta_{\\star}\\) given available data vector covariates \\(x_{\\star}\\) defining overall intercept $$\\theta_{\\star}| x_{\\star},y .$$ simple common case arises one observation (summary statistic) per trial. normal endpoint, model simplifies standard normal-normal hierarchical model. notation, \\(=h=1,\\ldots,H\\) $$y_h|\\theta_h \\sim N(\\theta_h,s_h^2)$$ $$\\theta_h = \\mu + \\epsilon_h$$ $$\\epsilon_h \\sim N(0,\\tau^2),$$ common \\(\\mu\\) used (intercept) parameter \\(\\beta_1\\). Since covariates, MAP prior simply \\(Pr(\\theta_{\\star} | y_1,\\ldots,y_H)\\). hierarchical model compromise two extreme cases full pooling (\\(\\tau=0\\), full borrowing, discounting) pooling (\\(\\tau=\\infty\\), borrowing, stratification). information content historical data grows H (number historical data items) indefinitely full pooling whereas information gained stratified analysis. fixed \\(\\tau\\), maximum effective sample size MAP prior \\(n_\\infty\\) (\\(H\\rightarrow \\infty\\)), normal endpoint fixed \\(\\sigma\\) $$n_\\infty = \\left(\\frac{\\tau^2}{\\sigma^2}\\right)^{-1},$$ (Neuenschwander et al., 2010). Hence, ratio \\(\\tau/\\sigma\\) limits amount information MAP prior equivalent . allows classification \\(\\tau\\) values relation \\(\\sigma\\), crucial define prior \\(P_\\tau\\). following classification useful clinical trial setting: formula \\(n_\\infty\\) assumes known \\(\\tau\\). unrealistic -trial heterogeneity parameter often well estimable, particular number trials small (H small). table helps specify prior distribution \\(\\tau\\) appropriate given context defines crucial parameter \\(\\sigma\\). binary Poisson endpoints, normal approximations can used determine \\(\\sigma\\). See examples concrete cases. design matrix \\(X\\) defined formula linear predictor always form response ~ predictor | grouping, follows glm conventions. syntax extended include specification grouping (example study) factor data horizontal bar, |. bar separates optionally specified grouping level, .e. binary endpoint case cbind(r, n-r) ~ 1 | study. default assumed row corresponds individual group (individual parameter estimated). Specifics different endpoints : normal family=gaussian assumes identity link function. response given matrix two columns first column observed mean value \\(y_{ih}\\) second column standard error \\(se_{ih}\\) (mean). Additionally, recommended specify weight argument number units contributed (mean) measurement \\(y_{ih}\\). information used estimate \\(\\sigma\\). binary family=binomial assumes logit link function. response must given two-column matrix number responders \\(r\\) (first column) non-responders \\(n-r\\) (second column). Poisson family=poisson assumes log link function. response vector counts. total exposure times can specified offset, linearly added linear predictor. offset can given part formula, y ~ 1 + offset(log(exposure)) offset argument gMAP. Note exposure unit must given log-offset.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"methods-by-generic-","dir":"Reference","previous_headings":"","what":"Methods (by generic)","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"print(gMAP): displays summary gMAP analysis. fitted(gMAP): returns quantiles posterior shrinkage estimates data item used analysis given gMAP object. coef(gMAP): returns quantiles predictive distribution. User can choose type result response link scale. .matrix(gMAP): extracts posterior sample model. summary(gMAP): returns summaries gMAP. analysis. Output gMAPsummary object, list containing tau posterior summary heterogeneity standard deviation beta posterior summary regression coefficients theta.pred summary predictive distribution (given dependence type argument either response link scale) theta posterior summary mean estimate (also depends type argument)","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"differential-discounting","dir":"Reference","previous_headings":"","what":"Differential Discounting","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"model assumes -group standard deviation \\(\\tau\\), implies data equally relevant. assumption can relaxed one \\(\\tau\\). , $$\\epsilon_h \\sim N(0,\\tau_{s(h)}^2)$$ \\(s(h)\\) assignes group \\(h\\) one \\(S\\) -group heterogeneity strata. example, situation two randomized four observational studies, one may want assume \\(\\tau_1\\) (trials 1 2) \\(\\tau_2\\) (trials 3-6) -trial standard deviations control means. heterogeneity (less relevance) observational studies can expressed appropriate priors \\(\\tau_1\\) \\(\\tau_2\\). case, \\(S=2\\) strata assignments (see tau.strata argument) \\(s(1)=s(2)=1, s(3)=\\ldots=s(6)=2\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"prior-specification","dir":"Reference","previous_headings":"","what":"Prior Specification","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"prior distribution regression coefficients \\(\\beta\\) normal. single number given, used standard deviation default mean 0 used. vector given, must length number covariates defined used standard deviation. matrix single row given, first row used mean second row used standard deviation regression coefficients. Lastly, two-column matrix (mean standard deviation columns) many columns regression coefficients can given. recommended always specify beta.prior. Per default mean 0 set. standard deviation set 2 binary case, 100 * sd(y) normal case sd(log(y + 0.5 + offset)) Poisson case. -trial heterogeniety \\(\\tau\\) prior, dispersion parameter must always given exchangeability stratum. different tau.prior distributions, two parameters needed one set default value applicable: prior distribution default location parameter, vector length equal number exchangability strata can given. Otherwise, two-column matrix many rows exchangability strata must given, except single \\(\\tau\\) stratum, vector length two defines parameters b.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"random-seed","dir":"Reference","previous_headings":"","what":"Random seed","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"MAP analysis performed using Markov-Chain-Monte-Carlo (MCMC) rstan. MCMC stochastic algorithm. obtain exactly reproducible results must use set.seed function calling gMAP. See RBesT overview page global options setting MCMC simulation parameters.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"Neuenschwander B, Capkun-Niggli G, Branson M, Spiegelhalter DJ. Summarizing historical information controls clinical trials. Clin Trials. 2010; 7(1):5-18 Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032. Weber S, Li Y, Seaman III J.W., Kakizume T, Schmidli H. Applying Meta-Analytic Predictive Priors R Bayesian evidence synthesis tools. JSS 2021; 100(19):1-32","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/gMAP.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Meta-Analytic-Predictive Analysis for Generalized Linear Models — gMAP","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) # Binary data example 1 # Mean response rate is ~0.25. For binary endpoints # a conservative choice for tau is a HalfNormal(0,1) as long as # the mean response rate is in the range of 0.2 to 0.8. For # very small or large rates consider the n_infinity approach # illustrated below. # for exact reproducible results, the seed must be set set.seed(34563) map_AS <- gMAP(cbind(r, n - r) ~ 1 | study, family = binomial, data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2 ) #> Assuming default prior location for beta: 0 #> Warning: The largest R-hat is 1.11, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Warning: Maximal Rhat > 1.1. Consider increasing RBesT.MC.warmup MCMC parameter. #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. print(map_AS) #> Generalized Meta Analytic Predictive Prior Analysis #> #> Call: gMAP(formula = cbind(r, n - r) ~ 1 | study, family = binomial, #> data = AS, tau.dist = \"HalfNormal\", tau.prior = 1, beta.prior = 2) #> #> Exchangeability tau strata: 1 #> Prediction tau stratum : 1 #> Maximal Rhat : 1.11 #> #> Between-trial heterogeneity of tau prediction stratum #> mean sd 2.5% 50% 97.5% #> 0.370 0.163 0.110 0.352 0.764 #> #> MAP Prior MCMC sample #> mean sd 2.5% 50% 97.5% #> 0.2580 0.0817 0.1230 0.2510 0.4460 #> Warning: Parts of the model have not converged (some Rhats are > 1.1). #> Be careful when analysing the results! It is recommend to run #> more iterations and/or setting stronger priors. # obtain numerical summaries map_sum <- summary(map_AS) print(map_sum) #> Heterogeneity parameter tau per stratum: #> mean sd 2.5% 50% 97.5% #> tau[1] 0.37 0.163 0.11 0.352 0.764 #> #> Regression coefficients: #> mean sd 2.5% 50% 97.5% #> (Intercept) -1.12 0.178 -1.47 -1.11 -0.767 #> #> Mean estimate MCMC sample: #> mean sd 2.5% 50% 97.5% #> theta_resp 0.248 0.033 0.187 0.247 0.317 #> #> MAP Prior MCMC sample: #> mean sd 2.5% 50% 97.5% #> theta_resp_pred 0.258 0.0817 0.123 0.251 0.446 names(map_sum) #> [1] \"tau\" \"beta\" \"theta.pred\" \"theta\" # [1] \"tau\" \"beta\" \"theta.pred\" \"theta\" map_sum$theta.pred #> mean sd 2.5% 50% 97.5% #> theta_resp_pred 0.2576768 0.08166927 0.1232554 0.2508299 0.4464658 # \\donttest{ # graphical model checks (returns list of ggplot2 plots) map_checks <- plot(map_AS) # forest plot with shrinkage estimates map_checks$forest_model # density of MAP prior on response scale map_checks$densityThetaStar # density of MAP prior on link scale map_checks$densityThetaStarLink # } # obtain shrinkage estimates fitted(map_AS) #> mean sd 2.5% 50% 97.5% #> Study 1 0.2245230 0.03009877 0.16467408 0.2255518 0.2698386 #> Study 2 0.2600974 0.05160094 0.17318985 0.2610201 0.3745415 #> Study 3 0.3157218 0.06628311 0.21188389 0.3041774 0.4656744 #> Study 4 0.2440305 0.04812868 0.15154707 0.2442546 0.3333963 #> Study 5 0.2681039 0.03179363 0.21285005 0.2633981 0.3412085 #> Study 6 0.2670423 0.05109495 0.19112391 0.2609730 0.3660353 #> Study 7 0.1704818 0.04185255 0.08821842 0.1727647 0.2466163 #> Study 8 0.2649455 0.04246509 0.20001270 0.2574109 0.3462487 # regression coefficients coef(map_AS) #> mean sd 2.5% 50% 97.5% #> (Intercept) -1.11748 0.1782488 -1.468582 -1.113787 -0.7667301 # finally fit MAP prior with parametric mixture map_mix <- mixfit(map_AS, Nc = 2) plot(map_mix)$mix # \\donttest{ # optionally select number of components automatically via AIC map_automix <- automixfit(map_AS) plot(map_automix)$mix # } # Normal example 2, see normal vignette # Prior considerations # The general principle to derive a prior for tau can be based on the # n_infinity concept as discussed in Neuenschwander et al., 2010. # This assumes a normal approximation which applies for the colitis # data set as: p_bar <- mean(with(colitis, r / n)) s <- round(1 / sqrt(p_bar * (1 - p_bar)), 1) # s is the approximate sampling standard deviation and a # conservative prior is tau ~ HalfNormal(0,s/2) tau_prior_sd <- s / 2 # Evaluate HalfNormal prior for tau tau_cat <- c( pooling = 0, small = 0.0625, moderate = 0.125, substantial = 0.25, large = 0.5, veryLarge = 1, stratified = Inf ) # Interval probabilites (basically saying we are assuming # heterogeniety to be smaller than very large) diff(2 * pnorm(tau_cat * s, 0, tau_prior_sd)) #> small moderate substantial large veryLarge stratified #> 0.09947645 0.09793620 0.18551227 0.29976457 0.27181024 0.04550026 # Cumulative probabilities as 1-F 1 - 2 * (pnorm(tau_cat * s, 0, tau_prior_sd) - 0.5) #> pooling small moderate substantial large veryLarge #> 1.00000000 0.90052355 0.80258735 0.61707508 0.31731051 0.04550026 #> stratified #> 0.00000000 ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/integrate_density_log.html","id":null,"dir":"Reference","previous_headings":"","what":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","title":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","text":"integrate density logit space split component quantile function component used. ensures R implementation quantile function always used.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/integrate_density_log.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","text":"","code":"integrate_density_log( log_integrand, mix, Lplower = -Inf, Lpupper = Inf, eps = getOption(\"RBesT.integrate_prob_eps\", 1e-06) )"},{"path":"https://opensource.nibr.com/RBesT/reference/integrate_density_log.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"internal function used for integration of densities which appears to be much more stable from -Inf to +Inf in the logit space while the density to be integrated recieves inputs from 0 to 1 such that the inverse distribution function must be used. The integral solved is int_x dmix(mix,x) integrand(x) where integrand must be given as log and we integrate over the support of mix. — integrate_density_log","text":"log_integrand function integrate must return log(f) mix density integrate Lplower logit lower cumulative density Lpupper logit upper cumulative density","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/knn.html","id":null,"dir":"Reference","previous_headings":"","what":"k nearest neighbor algorithm for multi-variate data — knn","title":"k nearest neighbor algorithm for multi-variate data — knn","text":"k nearest neighbor algorithm multi-variate data","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/knn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"k nearest neighbor algorithm for multi-variate data — knn","text":"","code":"knn(X, K = 2, init, Ninit = 50, verbose = FALSE, tol, Niter.max = 500)"},{"path":"https://opensource.nibr.com/RBesT/reference/knn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"k nearest neighbor algorithm for multi-variate data — knn","text":"X data matrix, .e. observations X dimensions K number clusters use init list p mu used initialization Ninit number samples used per cluster init argument given verbose allows print progress information; verbose mode cluster memberships added output tol smaller changes tol objective function indicate convergence, missing chosen automatically 1/5 smallest sample variance per dimension Niter.max maximum number admissible iterations","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":null,"dir":"Reference","previous_headings":"","what":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"Read set likelihood distribution corresponding conjugate prior distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"","code":"likelihood(mix) likelihood(mix) <- value"},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"mix Prior mixture distribution. value New likelihood. changed Gamma priors supported either Poisson (value=\"poisson\") Exponential (value=\"exp\") likelihoods.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"prior posterior distributions family, prior distribution called conjugate prior likelihood function.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/likelihood.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read and Set Likelihood to the Corresponding Conjugate Prior — likelihood","text":"","code":"# Gamma mixture gmix <- mixgamma(c(0.3, 20, 4), c(0.7, 50, 10)) # read out conjugate partner likelihood(gmix) #> [1] \"poisson\" ess(gmix) #> [1] 7.159378 # set conjugate partner likelihood(gmix) <- \"exp\" # ... which changes the interpretation of the mixture ess(gmix) #> [1] 34.93388"},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":null,"dir":"Reference","previous_headings":"","what":"Logit (log-odds) and inverse-logit function. — lodds","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"Calculates logit (log-odds) inverse-logit.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"","code":"logit(mu) inv_logit(eta)"},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"mu numeric object probabilies, values range [0,1]. Missing values (NAs) allowed. eta numeric object log-odds values, values range [-Inf,Inf]. Missing values (NAs) allowed.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"numeric object type mu eta containing logits inverse logit input values. logit inverse transformation equates $$\\mbox{logit}(\\mu) = \\log(\\mu/(1-\\mu))$$ $$\\mbox{logit}^{-1}(\\eta)= \\exp(\\eta)/(1 + \\exp(\\eta)).$$","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"Values mu equal 0 1 return -Inf Inf respectively.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/lodds.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Logit (log-odds) and inverse-logit function. — lodds","text":"","code":"logit(0.2) #> [1] -1.386294 inv_logit(-1.386) #> [1] 0.2000471"},{"path":"https://opensource.nibr.com/RBesT/reference/logLik.EM.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract log likelihood from fitted EM objects — logLik.EM","title":"Extract log likelihood from fitted EM objects — logLik.EM","text":"Extract log likelihood fitted EM objects","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/logLik.EM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract log likelihood from fitted EM objects — logLik.EM","text":"","code":"# S3 method for class 'EM' logLik(object, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/log_inv_logit.html","id":null,"dir":"Reference","previous_headings":"","what":"Numerically stable log of the inv_logit function — log_inv_logit","title":"Numerically stable log of the inv_logit function — log_inv_logit","text":"Numerically stable log inv_logit function","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/log_inv_logit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Numerically stable log of the inv_logit function — log_inv_logit","text":"","code":"log_inv_logit(mat)"},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":null,"dir":"Reference","previous_headings":"","what":"Mixture Distributions — mix","title":"Mixture Distributions — mix","text":"Density, cumulative distribution function, quantile function random number generation supported mixture distributions. (d/p/q/r)mix generic work mixture supported BesT (see table ).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mixture Distributions — mix","text":"","code":"dmix(mix, x, log = FALSE) pmix(mix, q, lower.tail = TRUE, log.p = FALSE) qmix(mix, p, lower.tail = TRUE, log.p = FALSE) rmix(mix, n) # S3 method for class 'mix' mix[[..., rescale = FALSE]]"},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mixture Distributions — mix","text":"mix mixture distribution object x, q vector quantiles log, log.p logical; TRUE (default), probabilities \\(p\\) given \\(\\log(p)\\) lower.tail logical; TRUE (default), probabilities \\(P[X\\leq x]\\) otherwise, \\(P[X>x]\\) p vector probabilities n number observations. length(n) > 1, length taken number required ... components subset given mixture. rescale logical; TRUE, mixture weights rescaled sum 1","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mixture Distributions — mix","text":"dmix gives weighted sum densities component. pmix calculates distribution function evaluating weighted sum components distribution function. qmix returns quantile given p using distribution function monotonous hence gradient based minimization scheme can used find matching quantile q. rmix generates random sample size n first sampling latent component indicator range \\(1..K\\) draw function samples component random draw using respective sampling function. rnorm function returns random draws numerical vector additional attribute ind gives sampled component indicator.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Mixture Distributions — mix","text":"mixture distribution defined linear superposition \\(K\\) densities distributional class. mixture distributions supported form $$f(x,\\mathbf{w},\\mathbf{},\\mathbf{b}) = \\sum_{k=1}^K w_k \\, f_k(x,a_k,b_k).$$ \\(w_k\\) mixing coefficients must sum \\(1\\). Moreover, density \\(f\\) assumed parametrized two parameters component \\(k\\) defined triplet, \\((w_k,a_k,b_k)\\). Individual mixture components can extracted using [[ operator, see examples . supported densities normal, beta gamma can instantiated mixnorm, mixbeta, mixgamma, respectively. addition, respective predictive distributions supported. can obtained calling preddist returns appropriate normal, beta-binomial Poisson-gamma mixtures. convenience summary function defined mixtures. returns mean, standard deviation requested quantiles can specified argument probs.","code":""},{"path":[]},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mixture Distributions — mix","text":"","code":"## a beta mixture bm <- mixbeta(weak = c(0.2, 2, 10), inf = c(0.4, 10, 100), inf2 = c(0.4, 30, 80)) ## extract the two most informative components bm[[c(2, 3)]] #> Univariate beta mixture #> Mixture Components: #> inf inf2 #> w 0.4 0.4 #> a 10.0 30.0 #> b 100.0 80.0 ## rescaling needed in order to plot plot(bm[[c(2, 3), rescale = TRUE]]) summary(bm) #> mean sd 2.5% 50.0% 97.5% #> 0.17878788 0.09898301 0.04389723 0.15654866 0.35327791"},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":null,"dir":"Reference","previous_headings":"","what":"Beta Mixture Density — mixbeta","title":"Beta Mixture Density — mixbeta","text":"Beta mixture density auxilary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Beta Mixture Density — mixbeta","text":"","code":"mixbeta(..., param = c(\"ab\", \"ms\", \"mn\")) ms2beta(m, s, drop = TRUE) mn2beta(m, n, drop = TRUE) # S3 method for class 'betaMix' print(x, ...) # S3 method for class 'betaBinomialMix' print(x, ...) # S3 method for class 'betaMix' summary(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'betaBinomialMix' summary(object, probs = c(0.025, 0.5, 0.975), ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Beta Mixture Density — mixbeta","text":"... List mixture components. param Determines parameters list interpreted. See details. m Vector means beta mixture components. s Vector standard deviations beta mixture components. drop Delete dimensions array one level. n Vector number observations. x mixture print object Beta mixture object. probs Quantiles reported summary function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Beta Mixture Density — mixbeta","text":"mixbeta returns beta mixture specified mixture components. ms2beta mn2beta return equivalent natural b parametrization given parameters m, s, n.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Beta Mixture Density — mixbeta","text":"entry ... argument list expected triplet numbers defines weight \\(w_k\\), first second parameter mixture component \\(k\\). triplet can optionally named used appropriately. first second parameter can given different parametrizations set param option: ab Natural parametrization Beta density (=shape1 b=shape2). Default. ms Mean standard deviation, \\(m=/(+b)\\) \\(s=\\sqrt{\\frac{m(1-m)}{1+n}}\\), \\(n=+b\\) number observations. Note \\(s\\) must less \\(\\sqrt{m(1-m)}\\). mn Mean number observations, \\(n=+b\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixbeta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Beta Mixture Density — mixbeta","text":"","code":"## a beta mixture bm <- mixbeta(rob = c(0.2, 2, 10), inf = c(0.4, 10, 100), inf2 = c(0.4, 30, 80)) # mean/standard deviation parametrization bm2 <- mixbeta(rob = c(0.2, 0.3, 0.2), inf = c(0.8, 0.4, 0.01), param = \"ms\") # mean/observations parametrization bm3 <- mixbeta(rob = c(0.2, 0.3, 5), inf = c(0.8, 0.4, 30), param = \"mn\") # even mixed is possible bm4 <- mixbeta(rob = c(0.2, mn2beta(0.3, 5)), inf = c(0.8, ms2beta(0.4, 0.1))) # print methods are defined bm4 #> Univariate beta mixture #> Mixture Components: #> rob inf #> w 0.2 0.8 #> a 1.5 9.2 #> b 3.5 13.8 print(bm4) #> Univariate beta mixture #> Mixture Components: #> rob inf #> w 0.2 0.8 #> a 1.5 9.2 #> b 3.5 13.8"},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine Mixture Distributions — mixcombine","title":"Combine Mixture Distributions — mixcombine","text":"Combining mixture distributions class form new mixture.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine Mixture Distributions — mixcombine","text":"","code":"mixcombine(..., weight, rescale = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine Mixture Distributions — mixcombine","text":"... arbitrary number mixtures distributional class. component values mixture weight model parameters. weight relative weight component new mixture distribution. vector must length input mixtures components. default value gives equal weight component. rescale boolean value indicates weights rescaled sum 1.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine Mixture Distributions — mixcombine","text":"R-object new mixture distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Combine Mixture Distributions — mixcombine","text":"Combines mixtures class random variable form new mixture distribution.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixcombine.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine Mixture Distributions — mixcombine","text":"","code":"# beta with two informative components bm <- mixbeta(inf = c(0.5, 10, 100), inf2 = c(0.5, 30, 80)) # robustified with mixcombine, i.e. a 10% uninformative part added unif <- mixbeta(rob = c(1, 1, 1)) mixcombine(bm, unif, weight = c(9, 1)) #> Univariate beta mixture #> Mixture Components: #> inf inf2 rob #> w 0.45 0.45 0.10 #> a 10.00 30.00 1.00 #> b 100.00 80.00 1.00"},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":null,"dir":"Reference","previous_headings":"","what":"Difference of mixture distributions — mixdiff","title":"Difference of mixture distributions — mixdiff","text":"Density, cumulative distribution function, quantile function random number generation difference two mixture distributions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Difference of mixture distributions — mixdiff","text":"","code":"dmixdiff(mix1, mix2, x) pmixdiff(mix1, mix2, q, lower.tail = TRUE) qmixdiff(mix1, mix2, p, lower.tail = TRUE) rmixdiff(mix1, mix2, n)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Difference of mixture distributions — mixdiff","text":"mix1 first mixture density mix2 second mixture density x vector values density values computed q vector quantiles cumulative probabilities computed lower.tail logical; TRUE (default), probabilities P[X <= x], otherwise P[X > x]. p vector cumulative probabilities quantiles computed n size random sample","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Difference of mixture distributions — mixdiff","text":"Respective density, quantile, cumulative density random numbers.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Difference of mixture distributions — mixdiff","text":"\\(x_1 \\sim f_1(x_1)\\) \\(x_2 \\sim f_2(x_2)\\), density difference \\(d \\equiv x_1 - x_2\\) given $$f_d(d) = \\int f_1(u) \\, f_2(u - d) \\, du.$$ cumulative distribution function equates $$F_d(d) = \\int f_1(u) \\, (1-F_2(u-d)) \\, du.$$ integrals performed full support densities use numerical integration function integrate.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdiff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Difference of mixture distributions — mixdiff","text":"","code":"# 1. Difference between two beta distributions, i.e. Pr( mix1 - mix2 > 0) mix1 <- mixbeta(c(1, 11, 4)) mix2 <- mixbeta(c(1, 8, 7)) pmixdiff(mix1, mix2, 0, FALSE) #> [1] 0.8817696 # Interval probability, i.e. Pr( 0.3 > mix1 - mix2 > 0) pmixdiff(mix1, mix2, 0.3) - pmixdiff(mix1, mix2, 0) #> [1] 0.6005884 # 2. two distributions, one of them a mixture m1 <- mixbeta(c(1, 30, 50)) m2 <- mixbeta(c(0.75, 20, 50), c(0.25, 1, 1)) # random sample of difference set.seed(23434) rM <- rmixdiff(m1, m2, 1E4) # histogram of random numbers and exact density hist(rM, prob = TRUE, new = TRUE, nclass = 40) curve(dmixdiff(m1, m2, x), add = TRUE, n = 51) # threshold probabilities for difference, at 0 and 0.2 pmixdiff(m1, m2, 0) #> [1] 0.2467158 mean(rM < 0) #> [1] 0.2471 pmixdiff(m1, m2, 0.2) #> [1] 0.9025757 mean(rM < 0.2) #> [1] 0.907 # median of difference mdn <- qmixdiff(m1, m2, 0.5) mean(rM < mdn) #> [1] 0.504 # 95%-interval qmixdiff(m1, m2, c(0.025, 0.975)) #> [1] -0.5257954 0.2877204 quantile(rM, c(0.025, 0.975)) #> 2.5% 97.5% #> -0.5232376 0.2862964"},{"path":"https://opensource.nibr.com/RBesT/reference/mixdist3.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to instantiate 2 parameter mixture densities. — mixdist3","title":"Utility function to instantiate 2 parameter mixture densities. — mixdist3","text":"Utility function instantiate 2 parameter mixture densities.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixdist3.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to instantiate 2 parameter mixture densities. — mixdist3","text":"","code":"mixdist3(...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit of Mixture Densities to Samples — mixfit","title":"Fit of Mixture Densities to Samples — mixfit","text":"Expectation-Maximization (EM) based fitting parametric mixture densities numerical samples. provides convenient approach approximate MCMC samples parametric mixture distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit of Mixture Densities to Samples — mixfit","text":"","code":"mixfit(sample, type = c(\"norm\", \"beta\", \"gamma\", \"mvnorm\"), thin, ...) # Default S3 method mixfit(sample, type = c(\"norm\", \"beta\", \"gamma\", \"mvnorm\"), thin, ...) # S3 method for class 'gMAP' mixfit(sample, type, thin, ...) # S3 method for class 'gMAPpred' mixfit(sample, type, thin, ...) # S3 method for class 'array' mixfit(sample, type, thin, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit of Mixture Densities to Samples — mixfit","text":"sample Sample fitted. type Mixture density use. Can either norm, beta gamma. thin Thinning applied sample. See description default behavior. ... Parameters passed low-level EM fitting functions. Parameter Nc mandatory.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit of Mixture Densities to Samples — mixfit","text":"mixture object according requested type returned. object additional information attached, .e. log-likelihood can queried diagnostic plots can generated. See links .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fit of Mixture Densities to Samples — mixfit","text":"Parameters EM fitting functions Nc Number mixture components. Required parameter. mix_init Initial mixture density. missing (default) k-nearest-neighbor algorithm used find initial mixture density. Ninit Number data points used initialization. Defaults 50. verbose set TRUE function inform fitting process maxIter Maximal number iterations. Defaults 500. tol Defines convergence criteria upper bound change log-likelihood, .e. derivative (respect iterations) log-likelihood falls tol, function declares convergence stops. eps Must triplet numbers set desired accuracy inferred parameters per mixture component. See description parameters used EM. EM stopped running mean absolute difference last successive Neps estimates given eps parameters. Defaults 5E-3 parameter. Neps Number iterations used running mean parameter estimates test convergence. Defaults 5. constrain_gt1 Logical value controlling Beta EM constrains parameters & b greater 1. default constraints turned (new since 1.6-0). default EM convergence declared desired accuracy parameters reached last Neps estimates. tol Neps specified, whatever criterion met first stop EM. parameters per component \\(k\\) used internally fitting different EM procedures: normal \\(logit(w_k), \\mu_k, \\log(\\sigma_k)\\) beta \\(logit(w_k), \\log(a_k), \\log(b_k)\\) constrained beta \\(logit(w_k), \\log(a_k-1), \\log(b_k-1)\\) gamma \\(logit(w_k), \\log(\\alpha_k), \\log(\\beta_k)\\) Note: Whenever mix_init argument given, EM fitting routines assume data vector given random order. unlikely event EM gets caught local extremum, random reordering data vector may alleviate issue.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Fit of Mixture Densities to Samples — mixfit","text":"mixfit(default): Performs EM fit given sample. Thinning applied thin specified. mixfit(gMAP): Fits default predictive distribution gMAP analysis. Automatically obtains predictive distribution intercept case response scale mixture gMAP object. binomial case beta mixture, gaussian case normal mixture Poisson case gamma mixture used. gaussian case, resulting normal mixture set reference scale estimated sigma gMAP call. mixfit(gMAPpred): Fits mixture density prediction gMAP prediction. mixfit(array): Fits mixture density MCMC sample. recommended provide thinning argument roughly yields independent draws (.e. use acf identify thinning lag small auto-correlation). input array expected 3 dimensions nested iterations, chains, draws.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Fit of Mixture Densities to Samples — mixfit","text":"Dempster .P., Laird N.M., Rubin D.B. Maximum Likelihood Incomplete Data via EM Algorithm. Journal Royal Statistical Society, Series B 1977; 39 (1): 1-38.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixfit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fit of Mixture Densities to Samples — mixfit","text":"","code":"bmix <- mixbeta(rob = c(0.2, 1, 1), inf = c(0.8, 10, 2)) bsamp <- rmix(bmix, 1000) bfit <- mixfit(bsamp, type = \"beta\", Nc = 2) # diagnostic plots can easily by generated from the EM fit with bfit.check <- plot(bfit) names(bfit.check) #> [1] \"mixdist\" \"mixdens\" \"mixecdf\" \"mix\" # check convergence of parameters bfit.check$mix bfit.check$mixdens bfit.check$mixecdf # obtain the log-likelihood logLik(bfit) #> 'log Lik.' 543.9702 (df=5) # or AIC AIC(bfit) #> [1] -1077.94"},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":null,"dir":"Reference","previous_headings":"","what":"The Gamma Mixture Distribution — mixgamma","title":"The Gamma Mixture Distribution — mixgamma","text":"gamma mixture density auxiliary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The Gamma Mixture Distribution — mixgamma","text":"","code":"mixgamma(..., param = c(\"ab\", \"ms\", \"mn\"), likelihood = c(\"poisson\", \"exp\")) ms2gamma(m, s, drop = TRUE) mn2gamma(m, n, likelihood = c(\"poisson\", \"exp\"), drop = TRUE) # S3 method for class 'gammaMix' print(x, ...) # S3 method for class 'gammaPoissonMix' print(x, ...) # S3 method for class 'gammaExpMix' print(x, ...) # S3 method for class 'gammaMix' summary(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'gammaPoissonMix' summary(object, probs = c(0.025, 0.5, 0.975), ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The Gamma Mixture Distribution — mixgamma","text":"... List mixture components. param Determines parameters list interpreted. See details. likelihood Defines likelihood Gamma density used (Poisson Exp). Defaults poisson. m Vector means Gamma mixture components s Vector standard deviations gamma mixture components, drop Delete dimensions array one level. n Vector sample sizes Gamma mixture components. x mixture print object Gamma mixture object. probs Quantiles reported summary function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The Gamma Mixture Distribution — mixgamma","text":"mixgamma returns gamma mixture specified mixture components. ms2gamma mn2gamma return equivalent natural b parametrization given parameters m, s, n.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"The Gamma Mixture Distribution — mixgamma","text":"entry ... argument list expected triplet numbers defines weight \\(w_k\\), first second parameter mixture component \\(k\\). triplet can optionally named used appropriately. first second parameter can given different parametrizations set param option: ab Natural parametrization Gamma density (=shape b=rate). Default. ms Mean standard deviation, \\(m=/b\\) \\(s=\\sqrt{}/b\\). mn Mean number observations. Translation natural parameter depends likelihood argument. Poisson likelihood \\(n=b\\) (\\(=m \\cdot n\\)), Exp likelihood \\(n=\\) (\\(b=n/m\\)).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixgamma.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"The Gamma Mixture Distribution — mixgamma","text":"","code":"# Gamma mixture with robust and informative component gmix <- mixgamma(rob = c(0.3, 20, 4), inf = c(0.7, 50, 10)) # objects can be printed gmix #> Univariate Gamma mixture #> Mixture Components: #> rob inf #> w 0.3 0.7 #> a 20.0 50.0 #> b 4.0 10.0 # or explicitly print(gmix) #> Univariate Gamma mixture #> Mixture Components: #> rob inf #> w 0.3 0.7 #> a 20.0 50.0 #> b 4.0 10.0 # summaries are defined summary(gmix) #> mean sd 2.5% 50.0% 97.5% #> 5.0000000 0.8514693 3.4362134 4.9560695 6.8210139 # sub-components may be extracted # by component number gmix[[2]] #> Univariate Gamma mixture #> Mixture Components: #> inf #> w 0.7 #> a 50.0 #> b 10.0 # or component name gmix[[\"inf\"]] #> Univariate Gamma mixture #> Mixture Components: #> inf #> w 0.7 #> a 50.0 #> b 10.0 # alternative mean and standard deviation parametrization gmsMix <- mixgamma(rob = c(0.5, 8, 0.5), inf = c(0.5, 9, 2), param = \"ms\") # or mean and number of observations parametrization gmnMix <- mixgamma(rob = c(0.2, 2, 1), inf = c(0.8, 2, 5), param = \"mn\") # and mixed parametrizations are also possible gfmix <- mixgamma(rob1 = c(0.15, mn2gamma(2, 1)), rob2 = c(0.15, ms2gamma(2, 5)), inf = c(0.7, 50, 10))"},{"path":"https://opensource.nibr.com/RBesT/reference/mixlink.html","id":null,"dir":"Reference","previous_headings":"","what":"takes x and transforms it according to the defined link function of the mixture — mixlink","title":"takes x and transforms it according to the defined link function of the mixture — mixlink","text":"takes x transforms according defined link function mixture","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixlink.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"takes x and transforms it according to the defined link function of the mixture — mixlink","text":"","code":"mixlink(mix, x)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":null,"dir":"Reference","previous_headings":"","what":"Multivariate Normal Mixture Density — mixmvnorm","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"multivariate normal mixture density auxiliary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"","code":"mixmvnorm(..., sigma, param = c(\"ms\", \"mn\")) # S3 method for class 'mvnormMix' print(x, ...) # S3 method for class 'mvnormMix' summary(object, ...) # S3 method for class 'mvnormMix' sigma(object, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"... List mixture components. sigma Reference covariance. param Determines parameters list interpreted. See details. x mixture print object Multivariate normal mixture object.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"Returns multivariate normal mixture specified mixture components.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"entry ... argument list numeric vector defining one component mixture multivariate normal distribution. first entry component defining vector weight mixture component followed vector means dimension finally specification covariance matrix, depends chosen parametrization. covariance matrix expected given numeric vector column-major format, standard conversion applied matrices vector concatenation function c. Please refer examples section . component defining vector can specified different ways determined param option: ms Mean vector covariance matrix s. Default. mn Mean vector number observations. n determines covariance component via relation \\(\\Sigma/n\\) \\(\\Sigma\\) known reference covariance. reference covariance \\(\\Sigma\\) known covariance normal-normal model (observation covariance). function sigma can used query reference covariance may also used assign new reference covariance, see examples . case sigma specified, user supply sigma argument functions require reference covariance.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixmvnorm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Multivariate Normal Mixture Density — mixmvnorm","text":"","code":"S <- diag(c(1, 2)) %*% matrix(c(1, 0.5, 0.5, 1), 2, 2) %*% diag(c(1, 2)) mvnm1 <- mixmvnorm( rob = c(0.2, c(0, 0), diag(c(5, 5))), inf = c(0.8, c(0.5, 1), S / 10), sigma = S ) print(mvnm1) #> Multivariate normal mixture #> Outcome dimension: 2 #> Reference covariance: #> 1 2 #> 1 1 1 #> 2 1 4 #> Mixture Components: #> rob inf #> w 0.2000000 0.8000000 #> m[1] 0.0000000 0.5000000 #> m[2] 0.0000000 1.0000000 #> s[1] 2.2360680 0.3162278 #> s[2] 2.2360680 0.6324555 #> rho[2,1] 0.0000000 0.5000000 summary(mvnm1) #> $mean #> 1 2 #> 0.4 0.8 #> #> $cov #> 1 2 #> 1 1.12 0.16 #> 2 0.16 1.48 #> set.seed(657846) mixSamp1 <- rmix(mvnm1, 500) colMeans(mixSamp1) #> 1 2 #> 0.3695877 0.7900870"},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":null,"dir":"Reference","previous_headings":"","what":"Normal Mixture Density — mixnorm","title":"Normal Mixture Density — mixnorm","text":"normal mixture density auxiliary functions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Normal Mixture Density — mixnorm","text":"","code":"mixnorm(..., sigma, param = c(\"ms\", \"mn\")) mn2norm(m, n, sigma, drop = TRUE) # S3 method for class 'normMix' print(x, ...) # S3 method for class 'normMix' summary(object, probs = c(0.025, 0.5, 0.975), ...) # S3 method for class 'normMix' sigma(object, ...) sigma(object) <- value"},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Normal Mixture Density — mixnorm","text":"... List mixture components. sigma Reference scale. param Determines parameters list interpreted. See details. m Vector means n Vector sample sizes. drop Delete dimensions array one level. x mixture print object Normal mixture object. probs Quantiles reported summary function. value New value reference scale sigma.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Normal Mixture Density — mixnorm","text":"Returns normal mixture specified mixture components. mn2norm returns mean standard deviation given mean sample size parametrization.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Normal Mixture Density — mixnorm","text":"entry ... argument list expected triplet numbers defines weight \\(w_k\\), first second parameter mixture component \\(k\\). triplet can optionally named used appropriately. first second parameter can given different parametrizations set param option: ms Mean standard deviation. Default. mn Mean number observations. n determines s via relation \\(s=\\sigma/\\sqrt{n}\\) \\(\\sigma\\) fixed reference scale. reference scale \\(\\sigma\\) fixed standard deviation one-parameter normal-normal model (observation standard deviation). function sigma can used query reference scale may also used assign new reference scale, see examples . case sigma specified, user supply sigma argument functions require reference scale.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Normal Mixture Density — mixnorm","text":"sigma(object) <- value: Allows assign new reference scale sigma.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixnorm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Normal Mixture Density — mixnorm","text":"","code":"nm <- mixnorm(rob = c(0.2, 0, 2), inf = c(0.8, 2, 2), sigma = 5) print(nm) #> Univariate normal mixture #> Reference scale: 5 #> Mixture Components: #> rob inf #> w 0.2 0.8 #> m 0.0 2.0 #> s 2.0 2.0 summary(nm) #> mean sd 2.5% 50.0% 97.5% #> 1.600000 2.154066 -2.708104 1.631171 5.740143 plot(nm) set.seed(57845) mixSamp <- rmix(nm, 500) plot(nm, samp = mixSamp) # support defined by quantiles qmix(nm, c(0.01, 0.99)) #> [1] -3.532815 6.491874 # density function dmix(nm, seq(-5, 5, by = 2)) #> [1] 0.002101903 0.019963080 0.087013571 0.176032663 0.153777890 0.053559868 # distribution function pmix(nm, seq(-5, 5, by = 2)) #> [1] 0.001428036 0.018329173 0.115153269 0.385122523 0.739808529 0.945312306 # the reference scale can be changed (it determines the ESS) ess(nm) #> Using default prior reference scale 5 #> [1] 5.404787 sigma(nm) <- 10 ess(nm) #> Using default prior reference scale 10 #> [1] 21.61915"},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot mixture distributions — mixplot","title":"Plot mixture distributions — mixplot","text":"Plotting mixture distributions","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot mixture distributions — mixplot","text":"","code":"# S3 method for class 'mix' plot(x, prob = 0.99, fun = dmix, log = FALSE, comp = TRUE, size = 1.25, ...) # S3 method for class 'mvnormMix' plot(x, prob = 0.99, fun = dmix, log = FALSE, comp = TRUE, size = 1.25, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot mixture distributions — mixplot","text":"x mixture distribution prob defining lower upper percentile x-axis. Defaults 99% central probability mass. fun function plot can dmix, qmix pmix. log log argument passed function specified fun. comp density function can set TRUE display colour-coded mixture component density addition density. size controls linesize plots. ... extra arguments passed plotted function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot mixture distributions — mixplot","text":"ggplot object returned.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot mixture distributions — mixplot","text":"Plot function mixture distribution objects. shows density/quantile/cumulative distribution (corresponds d/q/pmix function) specific central probability mass defined prob. default x-axis chosen show 99% probability density mass.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Plot mixture distributions — mixplot","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/mixplot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot mixture distributions — mixplot","text":"","code":"# beta with two informative components bm <- mixbeta(inf = c(0.5, 10, 100), inf2 = c(0.5, 30, 80)) plot(bm) plot(bm, fun = pmix) # for customizations of the plot we need to load ggplot2 first library(ggplot2) # show a histogram along with the density plot(bm) + geom_histogram( data = data.frame(x = rmix(bm, 1000)), aes(y = ..density..), bins = 50, alpha = 0.4 ) #> Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0. #> ℹ Please use `after_stat(density)` instead. #> ℹ The deprecated feature was likely used in the RBesT package. #> Please report the issue at . # \\donttest{ # note: we can also use bayesplot for histogram plots with a density ... library(bayesplot) mh <- mcmc_hist(data.frame(x = rmix(bm, 1000)), freq = FALSE) + overlay_function(fun = dmix, args = list(mix = bm)) # ...and even add each component for (k in 1:ncol(bm)) { mh <- mh + overlay_function(fun = dmix, args = list(mix = bm[[k]]), linetype = I(2)) } print(mh) #> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. # } # normal mixture nm <- mixnorm(rob = c(0.2, 0, 2), inf = c(0.8, 6, 2), sigma = 5) plot(nm) plot(nm, fun = qmix) # obtain ggplot2 object and change title pl <- plot(nm) pl + ggtitle(\"Normal 2-Component Mixture\")"},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":null,"dir":"Reference","previous_headings":"","what":"Mixture distributions as brms priors — mixstanvar","title":"Mixture distributions as brms priors — mixstanvar","text":"Adapter function converting mixture distributions use brm models via stanvar facility.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mixture distributions as brms priors — mixstanvar","text":"","code":"mixstanvar(..., verbose = FALSE)"},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mixture distributions as brms priors — mixstanvar","text":"... List mixtures convert. verbose Enables printing mixture priors chains start sample. Defaults FALSE.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mixture distributions as brms priors — mixstanvar","text":"stanvars object used argument stanvars argument brm model.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Mixture distributions as brms priors — mixstanvar","text":"declare mixture priors brm model requires two steps: First, mixture densities need converted adapter function mixstanvar stanvars object passed stanvars argument brm function. extends Stan code data generated brm mixture densities can used priors within brm model. second step assign parameters brm model mixture density prior using set_prior command brms. adapter function translates mixture distributions defined R respective mixture distribution Stan. Within Stan mixture distributions named accordance R functions used create respective mixture distributions. , mixture density normals created mixnorm referred mixnorm_lpdf Stan one can refer density mixnorm within set_prior functions (suffix _lpdf automatically added brm). arguments mixture distributions depend specific distribution type follows: arguments mixture densities refer different density parameters automatically extracted mixtures converted. Important argument names must used declare mixture prior. mixture convert part ... argument mixstanvar label determined using name given list. case name given, name R object used. declare prior parameter mixture distribution must used arguments following convention label_argument. Please refer examples section illustration. Note: Models created brm use default data-dependent centering covariates leading shift overall intercept. commonly desirable applications functionality. therefore strongly recommended pass option center=FALSE argument brms formula created bf function demonstrated example .","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/mixstanvar.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mixture distributions as brms priors — mixstanvar","text":"","code":"if (FALSE) { # \\dontrun{ # The mixstanvar adapter requires the optional packages brms and glue stopifnot(require(\"brms\"), require(\"glue\")) # Assume we prefer a logistic regression MCMC analysis rather than a # beta-binomial analysis for the responder endpoint of the ankylosing # spondylitis (AS) example. Reasons to prefer a regression analysis is # to allow for baseline covariate adjustments, for example. map_AS_beta <- mixbeta(c(0.62, 19.2, 57.8), c(0.38, 3.5, 9.4)) # First we need to convert the beta mixture to a respective mixture on # the log odds scale and approximate it with a normal mixture density. map_AS_samp <- rmix(map_AS_beta, 1E4) map_AS <- mixfit(logit(map_AS_samp), type = \"norm\", Nc = 2) # Trial results for placebo and secukinumab. trial <- data.frame( n = c(6, 24), r = c(1, 15), arm = factor(c(\"placebo\", \"secukinumab\")) ) # Define brms model such that the overall intercept corresponds to the # placebo response rate on the logit scale. NOTE: The use of # center=FALSE is required here as detailed in the note above. model <- bf(r | trials(n) ~ 1 + arm, family = binomial, center = FALSE) # to obtain detailed information on the declared model parameters use # get_prior(model, data=trial) # declare model prior with reference to mixture normal map prior... model_prior <- prior(mixnorm(map_w, map_m, map_s), coef = Intercept) + prior(normal(0, 2), class = b) # ... which must be made available to brms using the mixstanvar adapter. # Note that the map_AS prior is labeled \"map\" as referred to in the # previous prior declaration. analysis <- brm(model, data = trial, prior = model_prior, stanvars = mixstanvar(map = map_AS), seed = 365634, refresh = 0 ) # Let's compare the logistic regression estimate for the probability # of a positive treatment effect (secukinumab response rate exceeding # the response rate of placebo) to the direct beta-binomial analysis: hypothesis(analysis, \"armsecukinumab > 0\") post_secukinumab <- postmix(mixbeta(c(1, 0.5, 1)), r = 15, n = 24) post_placebo <- postmix(map_AS_beta, r = 1, n = 6) pmixdiff(post_secukinumab, post_placebo, 0, lower.tail = FALSE) # The posterior probability for a positive treatment effect # is very close to unity in both cases. } # }"},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":null,"dir":"Reference","previous_headings":"","what":"Operating Characteristics for 1 Sample Design — oc1S","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"oc1S function defines 1 sample design (prior, sample size, decision function) calculation frequency decision evaluated 1 conditional assuming known parameters. function returned performs actual operating characteristics calculations.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"","code":"oc1S(prior, n, decision, ...) # S3 method for class 'betaMix' oc1S(prior, n, decision, ...) # S3 method for class 'normMix' oc1S(prior, n, decision, sigma, eps = 1e-06, ...) # S3 method for class 'gammaMix' oc1S(prior, n, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"prior Prior analysis. n Sample size experiment. decision One-sample decision function use; see decision1S. ... Optional arguments. sigma fixed reference scale. left unspecified, default reference scale prior assumed. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"Returns function one argument theta calculates frequency decision function evaluated 1 defined 1 sample design. Note returned function takes vectors arguments.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"oc1S function defines 1 sample design returns function calculates operating characteristics. frequency decision function evaluated 1 assumption given true distribution data defined known parameter \\(\\theta\\). 1 sample design defined prior, sample size decision function, \\(D(y)\\). uniquely define decision boundary, see decision1S_boundary. calling oc1S function, internally critical value \\(y_c\\) (using decision1S_boundary) calculated function returns can used calculated desired frequency evaluated $$ F(y_c|\\theta). $$","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"oc1S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. oc1S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture prior mean. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function oc1S extra argument eps (defaults \\(10^{-6}\\)). critical value \\(y_c\\) searched region probability mass 1-eps \\(y\\). oc1S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function oc1S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/oc1S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Operating Characteristics for 1 Sample Design — oc1S","text":"","code":"# non-inferiority example using normal approximation of log-hazard # ratio, see ?decision1S for all details s <- 2 flat_prior <- mixnorm(c(1, 0, 100), sigma = s) nL <- 233 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) theta_c <- theta_ni - za * s / sqrt(n1) # standard NI design decA <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # double criterion design # statistical significance (like NI design) dec1 <- decision1S(1 - alpha, theta_ni, lower.tail = TRUE) # require mean to be at least as good as theta_c dec2 <- decision1S(0.5, theta_c, lower.tail = TRUE) # combination decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) theta_eval <- c(theta_a, theta_c, theta_ni) # evaluate different designs at two sample sizes designA_n1 <- oc1S(flat_prior, n1, decA) #> Using default prior reference scale 2 designA_nL <- oc1S(flat_prior, nL, decA) #> Using default prior reference scale 2 designC_n1 <- oc1S(flat_prior, n1, decComb) #> Using default prior reference scale 2 designC_nL <- oc1S(flat_prior, nL, decComb) #> Using default prior reference scale 2 # evaluate designs at the key log-HR of positive treatment (HR<1), # the indecision point and the NI margin designA_n1(theta_eval) #> [1] 0.80084529 0.49980774 0.04995032 designA_nL(theta_eval) #> [1] 0.92039728 0.64489439 0.04997268 designC_n1(theta_eval) #> [1] 0.80084529 0.49980774 0.04995032 designC_nL(theta_eval) #> [1] 0.84991646 0.49995959 0.02185859 # to understand further the dual criterion design it is useful to # evaluate the criterions separatley: # statistical significance criterion to warrant NI... designC1_nL <- oc1S(flat_prior, nL, dec1) #> Using default prior reference scale 2 # ... or the clinically determined indifference point designC2_nL <- oc1S(flat_prior, nL, dec2) #> Using default prior reference scale 2 designC1_nL(theta_eval) #> [1] 0.92039728 0.64489439 0.04997268 designC2_nL(theta_eval) #> [1] 0.84991646 0.49995959 0.02185859 # see also ?decision1S_boundary to see which of the two criterions # will drive the decision"},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":null,"dir":"Reference","previous_headings":"","what":"Operating Characteristics for 2 Sample Design — oc2S","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"oc2S function defines 2 sample design (priors, sample sizes & decision function) calculation operating characeristics. function returned calculates calculates frequency decision function evaluated 1 assuming known parameters.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"","code":"oc2S(prior1, prior2, n1, n2, decision, ...) # S3 method for class 'betaMix' oc2S(prior1, prior2, n1, n2, decision, eps, ...) # S3 method for class 'normMix' oc2S( prior1, prior2, n1, n2, decision, sigma1, sigma2, eps = 1e-06, Ngrid = 10, ... ) # S3 method for class 'gammaMix' oc2S(prior1, prior2, n1, n2, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"prior1 Prior sample 1. prior2 Prior sample 2. n1, n2 Sample size respective samples. Sample size n1 must greater 0 sample size n2 must greater equal 0. decision Two-sample decision function use; see decision2S. ... Optional arguments. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\). sigma1 fixed reference scale sample 1. left unspecified, default reference scale prior 1 assumed. sigma2 fixed reference scale sample 2. left unspecified, default reference scale prior 2 assumed. Ngrid Determines density discretization grid decision function evaluated (see details).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"Returns function called two arguments theta1 theta2 return frequencies decision function evaluated 1 whenever data distributed according known parameter values sample. Note returned function takes vector arguments.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"oc2S function defines 2 sample design returns function calculates operating characteristics. frequency decision function evaluated 1 assumption given true distribution data defined known parameter \\(\\theta_1\\) \\(\\theta_2\\). 2 sample design defined priors, sample sizes decision function, \\(D(y_1,y_2)\\). uniquely define decision boundary , see decision2S_boundary. Calling oc2S function calculates decision boundary \\(D_1(y_2)\\) (see decision2S_boundary) returns function can used calculate desired frequency evaluated $$ \\int f_2(y_2|\\theta_2) F_1(D_1(y_2)|\\theta_1) dy_2. $$ See examples specifics supported mixture priors.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"oc2S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. optional argument eps defined, approximate method used limits search decision boundary region 1-eps probability mass. useful designs large sample sizes exact approach costly calculate. oc2S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture priors means. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function two extra arguments (defaults): eps (\\(10^{-6}\\)) Ngrid (10). decision boundary searched region probability mass 1-eps, respectively \\(y_1\\) \\(y_2\\). continuous decision function evaluated discrete grid, determined spacing \\(\\delta_2 = \\sigma_2/\\sqrt{N_{grid}}\\). decision boundary evaluated discrete steps, spline used inter-polate decision boundary intermediate points. oc2S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function oc2S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y_1\\) \\(y_2\\), respectively.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/oc2S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Operating Characteristics for 2 Sample Design — oc2S","text":"","code":"# example from Schmidli et al., 2014 dec <- decision2S(0.975, 0, lower.tail = FALSE) prior_inf <- mixbeta(c(1, 4, 16)) prior_rob <- robustify(prior_inf, weight = 0.2, mean = 0.5) prior_uni <- mixbeta(c(1, 1, 1)) N <- 40 N_ctl <- N - 20 # compare designs with different priors design_uni <- oc2S(prior_uni, prior_uni, N, N_ctl, dec) design_inf <- oc2S(prior_uni, prior_inf, N, N_ctl, dec) design_rob <- oc2S(prior_uni, prior_rob, N, N_ctl, dec) # type I error curve(design_inf(x, x), 0, 1) curve(design_uni(x, x), lty = 2, add = TRUE) curve(design_rob(x, x), lty = 3, add = TRUE) # power curve(design_inf(0.2 + x, 0.2), 0, 0.5) curve(design_uni(0.2 + x, 0.2), lty = 2, add = TRUE) curve(design_rob(0.2 + x, 0.2), lty = 3, add = TRUE)"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":null,"dir":"Reference","previous_headings":"","what":"Diagnostic plots for EM fits — plot.EM","title":"Diagnostic plots for EM fits — plot.EM","text":"Produce diagnostic plots EM fits returned mixfit.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Diagnostic plots for EM fits — plot.EM","text":"","code":"# S3 method for class 'EM' plot(x, size = 1.25, link = c(\"identity\", \"logit\", \"log\"), ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Diagnostic plots for EM fits — plot.EM","text":"x EM fit size Optional argument passed ggplot2 routines control line thickness. link Choice applied link function. Can take one values identity (default), logit log. ... Ignored. Overlays fitted mixture density histogram density plot raw sample fitted. Applying link function can beneficial, example logit (log) link beta (gamma) mixtures obtained Binomial (Poisson) gMAP analysis.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Diagnostic plots for EM fits — plot.EM","text":"list ggplot plots diagnostics EM run. Detailed EM diagnostic plots included global option RBesT.verbose set TRUE. include plots parameters component vs iteration. plot mixture density histogram density fitted sample always returned.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Diagnostic plots for EM fits — plot.EM","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/plot.EM.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Diagnostic plots for EM fits — plot.EM","text":"","code":"bmix <- mixbeta(rob = c(0.2, 1, 1), inf = c(0.8, 10, 2)) bsamp <- rmix(bmix, 1000) bfit <- mixfit(bsamp, type = \"beta\", Nc = 2) pl <- plot(bfit) print(pl$mixdens) print(pl$mix) # \\donttest{ # a number of additional plots are generated in verbose mode .user_option <- options(RBesT.verbose = TRUE) pl_all <- plot(bfit) # recover previous user options options(.user_option) names(pl_all) #> [1] \"mixdist\" \"w\" \"a\" \"b\" \"lN\" \"Lm\" \"N\" #> [8] \"m\" \"Lw\" \"lli\" \"mixdens\" \"mixecdf\" \"mix\" # [1] \"mixdist\" \"a\" \"b\" \"w\" \"m\" \"N\" \"Lm\" \"lN\" \"Lw\" \"lli\" \"mixdens\" \"mixecdf\" \"mix\" # }"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":null,"dir":"Reference","previous_headings":"","what":"Diagnostic plots for gMAP analyses — plot.gMAP","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"Diagnostic plots gMAP analyses","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"","code":"# S3 method for class 'gMAP' plot(x, size = NULL, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"x gMAP object size Controls line sizes traceplots forest plot. ... Ignored.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"function returns list ggplot objects.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"Creates MCMC diagnostics forest plot (including model estimates) gMAP analysis. customized forest plot, please use dedicated function forest_plot.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/plot.gMAP.html","id":"customizing-ggplot-plots","dir":"Reference","previous_headings":"","what":"Customizing ggplot2 plots","title":"Diagnostic plots for gMAP analyses — plot.gMAP","text":"returned plot ggplot2 object. Please refer \"Customizing Plots\" vignette part RBesT documentation introduction. simple modifications (change labels, add reference lines, ...) consider commands found bayesplot-helpers. advanced customizations please use ggplot2 package directly. description common tasks can found R Cookbook full reference available commands can found ggplot2 documentation site.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":null,"dir":"Reference","previous_headings":"","what":"Probability of Success for a 1 Sample Design — pos1S","title":"Probability of Success for a 1 Sample Design — pos1S","text":"pos1S function defines 1 sample design (prior, sample size, decision function) calculation frequency decision evaluated 1 assuming distribution parameter. function returned performs actual operating characteristics calculations.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Probability of Success for a 1 Sample Design — pos1S","text":"","code":"pos1S(prior, n, decision, ...) # S3 method for class 'betaMix' pos1S(prior, n, decision, ...) # S3 method for class 'normMix' pos1S(prior, n, decision, sigma, eps = 1e-06, ...) # S3 method for class 'gammaMix' pos1S(prior, n, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Probability of Success for a 1 Sample Design — pos1S","text":"prior Prior analysis. n Sample size experiment. decision One-sample decision function use; see decision1S. ... Optional arguments. sigma fixed reference scale. left unspecified, default reference scale prior assumed. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Probability of Success for a 1 Sample Design — pos1S","text":"Returns function takes single argument mix, mixture distribution control parameter. Calling function mixture distribution calculates PoS.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Probability of Success for a 1 Sample Design — pos1S","text":"pos1S function defines 1 sample design returns function calculates probability success. probability success frequency decision function evaluated 1 assumption given true distribution data implied distirbution parameter \\(\\theta\\). Calling pos1S function calculates critical value \\(y_c\\) returns function can used evaluate PoS different predictive distributions evaluated $$ \\int F(y_c|\\theta) p(\\theta) d\\theta, $$ \\(F\\) distribution function sampling distribution \\(p(\\theta)\\) specifies assumed true distribution parameter \\(\\theta\\). distribution \\(p(\\theta)\\) mixture distribution given mix argument function.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Probability of Success for a 1 Sample Design — pos1S","text":"pos1S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. pos1S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture prior mean. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function pos1S extra argument eps (defaults \\(10^{-6}\\)). critical value \\(y_c\\) searched region probability mass 1-eps \\(y\\). pos1S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function pos1S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y\\).","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/pos1S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Probability of Success for a 1 Sample Design — pos1S","text":"","code":"# non-inferiority example using normal approximation of log-hazard # ratio, see ?decision1S for all details s <- 2 flat_prior <- mixnorm(c(1, 0, 100), sigma = s) nL <- 233 theta_ni <- 0.4 theta_a <- 0 alpha <- 0.05 beta <- 0.2 za <- qnorm(1 - alpha) zb <- qnorm(1 - beta) n1 <- round((s * (za + zb) / (theta_ni - theta_a))^2) theta_c <- theta_ni - za * s / sqrt(n1) # assume we would like to conduct at an interim analysis # of PoS after having observed 20 events with a HR of 0.8. # We first need the posterior at the interim ... post_ia <- postmix(flat_prior, m = log(0.8), n = 20) #> Using default prior reference scale 2 # dual criterion decComb <- decision1S(c(1 - alpha, 0.5), c(theta_ni, theta_c), lower.tail = TRUE) # ... and we would like to know the PoS for a successful # trial at the end when observing 10 more events pos_ia <- pos1S(post_ia, 10, decComb) #> Using default prior reference scale 2 # our knowledge at the interim is just the posterior at # interim such that the PoS is pos_ia(post_ia) #> [1] 0.534741"},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":null,"dir":"Reference","previous_headings":"","what":"Probability of Success for 2 Sample Design — pos2S","title":"Probability of Success for 2 Sample Design — pos2S","text":"pos2S function defines 2 sample design (priors, sample sizes & decision function) calculation probability success. function returned calculates calculates frequency decision function evaluated 1 parameters distributed according given distributions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Probability of Success for 2 Sample Design — pos2S","text":"","code":"pos2S(prior1, prior2, n1, n2, decision, ...) # S3 method for class 'betaMix' pos2S(prior1, prior2, n1, n2, decision, eps, ...) # S3 method for class 'normMix' pos2S( prior1, prior2, n1, n2, decision, sigma1, sigma2, eps = 1e-06, Ngrid = 10, ... ) # S3 method for class 'gammaMix' pos2S(prior1, prior2, n1, n2, decision, eps = 1e-06, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Probability of Success for 2 Sample Design — pos2S","text":"prior1 Prior sample 1. prior2 Prior sample 2. n1, n2 Sample size respective samples. Sample size n1 must greater 0 sample size n2 must greater equal 0. decision Two-sample decision function use; see decision2S. ... Optional arguments. eps Support random variables determined interval covering 1-eps probability mass. Defaults \\(10^{-6}\\). sigma1 fixed reference scale sample 1. left unspecified, default reference scale prior 1 assumed. sigma2 fixed reference scale sample 2. left unspecified, default reference scale prior 2 assumed. Ngrid Determines density discretization grid decision function evaluated (see details).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Probability of Success for 2 Sample Design — pos2S","text":"Returns function called two arguments mix1 mix2 return frequencies decision function evaluated 1. argument expected mixture distribution representing assumed true distribution parameter group.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Probability of Success for 2 Sample Design — pos2S","text":"pos2S function defines 2 sample design returns function calculates probability success. probability success frequency decision function evaluated 1 assumption given true distribution data implied distirbution parameters \\(\\theta_1\\) \\(\\theta_2\\). calculation analogous operating characeristics oc2S difference instead assuming known (point-wise) true parameter values distribution specified parameter. Calling pos2S function calculates decision boundary \\(D_1(y_2)\\) returns function can used evaluate PoS different predictive distributions. evaluated $$ \\int\\int\\int f_2(y_2|\\theta_2) \\, p(\\theta_2) \\, F_1(D_1(y_2)|\\theta_1) \\, p(\\theta_1) \\, dy_2 d\\theta_2 d\\theta_1. $$ \\(F\\) distribution function sampling distribution \\(p(\\theta_1)\\) \\(p(\\theta_2)\\) specifies assumed true distribution parameters \\(\\theta_1\\) \\(\\theta_2\\), respectively. distribution \\(p(\\theta_1)\\) \\(p(\\theta_2)\\) mixture distribution given mix1 mix2 argument function. example, binary case integration predictive distribution, BetaBinomial, instead binomial distribution performed data space wherever decision function evaluated 1. aspects calculation 2-sample operating characteristics, see oc2S.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Probability of Success for 2 Sample Design — pos2S","text":"pos2S(betaMix): Applies binomial model mixture beta prior. calculations use exact expressions. optional argument eps defined, approximate method used limits search decision boundary region 1-eps probability mass. useful designs large sample sizes exact approach costly calculate. pos2S(normMix): Applies normal model known standard deviation \\(\\sigma\\) normal mixture priors means. consequence assumption known standard deviation, calculation discards sampling uncertainty second moment. function two extra arguments (defaults): eps (\\(10^{-6}\\)) Ngrid (10). decision boundary searched region probability mass 1-eps, respectively \\(y_1\\) \\(y_2\\). continuous decision function evaluated discrete grid, determined spacing \\(\\delta_2 = \\sigma_2/\\sqrt{N_{grid}}\\). decision boundary evaluated discrete steps, spline used inter-polate decision boundary intermediate points. pos2S(gammaMix): Applies Poisson model gamma mixture prior rate parameter. function pos2S takes extra argument eps (defaults \\(10^{-6}\\)) determines region probability mass 1-eps boundary searched \\(y_1\\) \\(y_2\\), respectively.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/pos2S.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Probability of Success for 2 Sample Design — pos2S","text":"","code":"# see ?decision2S for details of example priorT <- mixnorm(c(1, 0, 0.001), sigma = 88, param = \"mn\") priorP <- mixnorm(c(1, -49, 20), sigma = 88, param = \"mn\") # the success criteria is for delta which are larger than some # threshold value which is why we set lower.tail=FALSE successCrit <- decision2S(c(0.95, 0.5), c(0, 50), FALSE) # example interim outcome postP_interim <- postmix(priorP, n = 10, m = -50) #> Using default prior reference scale 88 postT_interim <- postmix(priorT, n = 20, m = -80) #> Using default prior reference scale 88 # assume that mean -50 / -80 were observed at the interim for # placebo control(n=10) / active treatment(n=20) which gives # the posteriors postP_interim #> Univariate normal mixture #> Reference scale: 88 #> Mixture Components: #> comp1 #> w 1.00000 #> m -49.33333 #> s 16.06653 postT_interim #> Univariate normal mixture #> Reference scale: 88 #> Mixture Components: #> comp1 #> w 1.00000 #> m -79.99600 #> s 19.67691 # then the PoS to succeed after another 20/30 patients is pos_final <- pos2S(postP_interim, postT_interim, 20, 30, successCrit) #> Using default prior 1 reference scale 88 #> Using default prior 2 reference scale 88 pos_final(postP_interim, postT_interim) #> [1] 0.145567"},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":null,"dir":"Reference","previous_headings":"","what":"Conjugate Posterior Analysis — postmix","title":"Conjugate Posterior Analysis — postmix","text":"Calculates posterior distribution data data given prior priormix, prior mixture conjugate distributions. posterior also mixture conjugate distributions.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conjugate Posterior Analysis — postmix","text":"","code":"postmix(priormix, data, ...) # S3 method for class 'betaMix' postmix(priormix, data, n, r, ...) # S3 method for class 'normMix' postmix(priormix, data, n, m, se, ...) # S3 method for class 'gammaMix' postmix(priormix, data, n, m, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conjugate Posterior Analysis — postmix","text":"priormix prior (mixture conjugate distributions). data individual data. individual data given, summary data provided (see ). ... includes arguments depend specific case, see description . n sample size. r Number successes. m Sample mean. se Sample standard error.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Conjugate Posterior Analysis — postmix","text":"conjugate prior-likelihood pair convenient property posterior distributional class prior. property also applies mixtures conjugate priors. Let $$p(\\theta;\\mathbf{w},\\mathbf{},\\mathbf{b})$$ denote conjugate mixture prior density data $$y|\\theta \\sim f(y|\\theta),$$ \\(f(y|\\theta)\\) likelihood. posterior mixture component \\(k\\) equal respective posterior \\(k\\)th prior component updated weights \\(w'_k\\), $$p(\\theta;\\mathbf{w'},\\mathbf{'},\\mathbf{b'}|y) = \\sum_{k=1}^K w'_k \\, p_k(\\theta;'_k,b'_k|y).$$ weight \\(w'_k\\) \\(k\\)th component determined marginal likelihood new data \\(y\\) \\(k\\)th prior distribution given predictive distribution \\(k\\)th component, $$w'_k \\propto w_k \\, \\int p_k(\\theta;a_k,b_k) \\, f(y|\\theta) \\, d\\theta \\equiv w^\\ast_k .$$ final weight \\(w'_k\\) given appropriate normalization, \\(w'_k = w^\\ast_k / \\sum_{k=1}^K w^\\ast_k\\). words, weight component \\(k\\) proportional likelihood data \\(y\\) generated respective component, .e. marginal probability; details, see example Schmidli et al., 2015. Note: prior weights \\(w_k\\) fixed, posterior weights \\(w'_k \\neq w_k\\) still change due changing normalization. data \\(y\\) can either given individual data summary data (sufficient statistics). See details implemented conjugate mixture prior densities.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Conjugate Posterior Analysis — postmix","text":"postmix(betaMix): Calculates posterior beta mixture distribution. individual data vector expected vector 0 1, .e. series Bernoulli experiments. Alternatively, sufficient statistics n r can given, .e. number trials successes, respectively. postmix(normMix): Calculates posterior normal mixture distribution sampling likelihood normal fixed standard deviation. Either individual data vector data can given sufficient statistics standard error se sample mean m. sample size n used instead sample standard error, reference scale prior used calculate standard error. standard error se sample size n given, reference scale prior updated; however recommended use command sigma set reference standard deviation. postmix(gammaMix): Calculates posterior gamma mixture distribution Poisson exponential likelihoods. Poisson case supported version.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Conjugate Posterior Analysis — postmix","text":"Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/postmix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conjugate Posterior Analysis — postmix","text":"","code":"# binary example with individual data (1=event,0=no event), uniform prior prior.unif <- mixbeta(c(1, 1, 1)) data.indiv <- c(1, 0, 1, 1, 0, 1) posterior.indiv <- postmix(prior.unif, data.indiv) print(posterior.indiv) #> Univariate beta mixture #> Mixture Components: #> comp1 #> w 1 #> a 5 #> b 3 # or with summary data (number of events and number of patients) r <- sum(data.indiv) n <- length(data.indiv) posterior.sum <- postmix(prior.unif, n = n, r = r) print(posterior.sum) #> Univariate beta mixture #> Mixture Components: #> comp1 #> w 1 #> a 5 #> b 3 # binary example with robust informative prior and conflicting data prior.rob <- mixbeta(c(0.5, 4, 10), c(0.5, 1, 1)) posterior.rob <- postmix(prior.rob, n = 20, r = 18) print(posterior.rob) #> Univariate beta mixture #> Mixture Components: #> comp1 comp2 #> w 0.002672948 0.997327052 #> a 22.000000000 19.000000000 #> b 12.000000000 3.000000000 # normal example with individual data sigma <- 88 prior.mean <- -49 prior.se <- sigma / sqrt(20) prior <- mixnorm(c(1, prior.mean, prior.se), sigma = sigma) data.indiv <- c(-46, -227, 41, -65, -103, -22, 7, -169, -69, 90) posterior.indiv <- postmix(prior, data.indiv) # or with summary data (mean and number of patients) mn <- mean(data.indiv) n <- length(data.indiv) posterior.sum <- postmix(prior, m = mn, n = n) #> Using default prior reference scale 88 print(posterior.sum) #> Univariate normal mixture #> Reference scale: 88 #> Mixture Components: #> comp1 #> w 1.00000 #> m -51.43333 #> s 16.06653"},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":null,"dir":"Reference","previous_headings":"","what":"Predictive Distributions for Mixture Distributions — preddist","title":"Predictive Distributions for Mixture Distributions — preddist","text":"Predictive distribution mixture conjugate distributions (beta, normal, gamma).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predictive Distributions for Mixture Distributions — preddist","text":"","code":"preddist(mix, ...) # S3 method for class 'betaMix' preddist(mix, n = 1, ...) # S3 method for class 'normMix' preddist(mix, n = 1, sigma, ...) # S3 method for class 'gammaMix' preddist(mix, n = 1, ...) # S3 method for class 'mvnormMix' preddist(mix, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predictive Distributions for Mixture Distributions — preddist","text":"mix mixture distribution ... includes arguments depend specific prior-likelihood pair, see description . n predictive sample size, set default 1 sigma fixed reference scale normal mixture. left unspecified, default reference scale mixture assumed.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predictive Distributions for Mixture Distributions — preddist","text":"function returns normal, beta gamma mixture matching predictive distribution \\(y_n\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predictive Distributions for Mixture Distributions — preddist","text":"Given mixture density (either posterior prior) $$p(\\theta,\\mathbf{w},\\mathbf{},\\mathbf{b})$$ data likelihood $$y|\\theta \\sim f(y|\\theta),$$ predictive distribution one-dimensional summary \\(y_n\\) $n$ future observations distributed $$y_n \\sim \\int p(\\theta,\\mathbf{w},\\mathbf{},\\mathbf{b}) \\, f(y_n|\\theta) \\, d\\theta .$$ distribution marginal distribution data mixture density. binary Poisson data \\(y_n = \\sum_{=1}^n y_i\\) sum future events. normal data, mean\\(\\bar{y}_n = 1/n \\sum_{=1}^n y_i\\).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Predictive Distributions for Mixture Distributions — preddist","text":"preddist(betaMix): Obtain matching predictive distribution beta distribution, BetaBinomial. preddist(normMix): Obtain matching predictive distribution Normal constant standard deviation. Note reference scale returned Normal mixture meaningless individual components updated appropriatley. preddist(gammaMix): Obtain matching predictive distribution Gamma. Poisson likelihoods supported. preddist(mvnormMix): Multivariate normal mixtures predictive densities (yet) supported.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/preddist.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predictive Distributions for Mixture Distributions — preddist","text":"","code":"# Example 1: predictive distribution from uniform prior. bm <- mixbeta(c(1, 1, 1)) bmPred <- preddist(bm, n = 10) # predictive proabilities and cumulative predictive probabilities x <- 0:10 d <- dmix(bmPred, x) names(d) <- x barplot(d) cd <- pmix(bmPred, x) names(cd) <- x barplot(cd) # median mdn <- qmix(bmPred, 0.5) mdn #> [1] 5 # Example 2: 2-comp Beta mixture bm <- mixbeta(inf = c(0.8, 15, 50), rob = c(0.2, 1, 1)) plot(bm) bmPred <- preddist(bm, n = 10) plot(bmPred) mdn <- qmix(bmPred, 0.5) mdn #> [1] 2 d <- dmix(bmPred, x = 0:10) # \\donttest{ n.sim <- 100000 r <- rmix(bmPred, n.sim) d #> [1] 0.08814590 0.19605661 0.23899190 0.19379686 0.11696528 0.05913205 #> [7] 0.03082078 0.02104347 0.01863583 0.01822732 0.01818400 table(r) / n.sim #> r #> 0 1 2 3 4 5 6 7 8 9 #> 0.08968 0.19746 0.23763 0.19322 0.11681 0.05847 0.03068 0.02091 0.01858 0.01803 #> 10 #> 0.01853 # } # Example 3: 3-comp Normal mixture m3 <- mixnorm(c(0.50, -0.2, 0.1), c(0.25, 0, 0.2), c(0.25, 0, 0.5), sigma = 10) print(m3) #> Univariate normal mixture #> Reference scale: 10 #> Mixture Components: #> comp1 comp2 comp3 #> w 0.50 0.25 0.25 #> m -0.20 0.00 0.00 #> s 0.10 0.20 0.50 summary(m3) #> mean sd 2.5% 50.0% 97.5% #> -0.1000000 0.2958040 -0.6426984 -0.1490997 0.6426789 plot(m3) predm3 <- preddist(m3, n = 2) #> Using default mixture reference scale 10 plot(predm3) print(predm3) #> Univariate normal mixture #> Reference scale: 10 #> Mixture Components: #> comp1 comp2 comp3 #> w 0.500000 0.250000 0.250000 #> m -0.200000 0.000000 0.000000 #> s 7.071775 7.073896 7.088723 summary(predm3) #> mean sd 2.5% 50.0% 97.5% #> -0.1000000 7.0772523 -13.9709762 -0.1000673 13.7713589"},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":null,"dir":"Reference","previous_headings":"","what":"Predictions from gMAP analyses — predict.gMAP","title":"Predictions from gMAP analyses — predict.gMAP","text":"Produces sample predictive distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predictions from gMAP analyses — predict.gMAP","text":"","code":"# S3 method for class 'gMAP' predict( object, newdata, type = c(\"response\", \"link\"), probs = c(0.025, 0.5, 0.975), na.action = na.pass, thin, ... ) # S3 method for class 'gMAPpred' print(x, digits = 3, ...) # S3 method for class 'gMAPpred' summary(object, ...) # S3 method for class 'gMAPpred' as.matrix(x, ...)"},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predictions from gMAP analyses — predict.gMAP","text":"newdata data.frame must contain columns input gMAP analysis. left , posterior prediction fitted data entries gMAP object performed (shrinkage estimates). type sets reported scale (response (default) link). probs defines quantiles reported. na.action handle missings. thin thinning applied derived gMAP object. ... ignored. x, object gMAP analysis object predictions performed digits number displayed significant digits.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predictions from gMAP analyses — predict.gMAP","text":"Predictions made using \\(\\tau\\) prediction stratum gMAP object. details syntax, please refer predict.glm example .","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/predict.gMAP.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predictions from gMAP analyses — predict.gMAP","text":"","code":"## Setting up dummy sampling for fast execution of example ## Please use 4 chains and 20x more warmup & iter in practice .user_mc_options <- options(RBesT.MC.warmup=50, RBesT.MC.iter=100, RBesT.MC.chains=2, RBesT.MC.thin=1) # create a fake data set with a covariate trans_cov <- transform(transplant, country = cut(1:11, c(0, 5, 8, Inf), c(\"CH\", \"US\", \"DE\"))) set.seed(34246) map <- gMAP(cbind(r, n - r) ~ 1 + country | study, data = trans_cov, tau.dist = \"HalfNormal\", tau.prior = 1, # Note on priors: we make the overall intercept weakly-informative # and the regression coefficients must have tighter sd as these are # deviations in the default contrast parametrization beta.prior = rbind(c(0, 2), c(0, 1), c(0, 1)), family = binomial, ## ensure fast example runtime thin = 1, chains = 1 ) #> Warning: The largest R-hat is 1.07, indicating chains have not mixed. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#r-hat #> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#bulk-ess #> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> https://mc-stan.org/misc/warnings.html#tail-ess #> Final MCMC sample equivalent to less than 1000 independent draws. #> Please consider increasing the MCMC simulation size. # posterior predictive distribution for each input data item (shrinkage estimates) pred_cov <- predict(map) pred_cov #> Meta-Analytic-Predictive Prior Predictions #> Scale: response #> #> Summary: #> mean sd 2.5% 50% 97.5% #> 1 0.205 0.0510 0.123 0.199 0.291 #> 2 0.195 0.0406 0.120 0.195 0.263 #> 3 0.216 0.0412 0.154 0.209 0.302 #> 4 0.253 0.0427 0.193 0.250 0.333 #> 5 0.197 0.0276 0.154 0.198 0.252 #> 6 0.184 0.0458 0.103 0.181 0.273 #> 7 0.238 0.0516 0.149 0.233 0.344 #> 8 0.168 0.0317 0.120 0.166 0.239 #> 9 0.241 0.0521 0.154 0.239 0.345 #> 10 0.174 0.0313 0.121 0.171 0.246 #> 11 0.243 0.0231 0.206 0.246 0.279 # extract sample as matrix samp <- as.matrix(pred_cov) # predictive distribution for each input data item (if the input studies were new ones) pred_cov_pred <- predict(map, trans_cov) pred_cov_pred #> Meta-Analytic-Predictive Prior Predictions #> Scale: response #> #> Summary: #> mean sd 2.5% 50% 97.5% #> 1 0.210 0.0650 0.0979 0.198 0.323 #> 2 0.221 0.0749 0.1210 0.220 0.379 #> 3 0.220 0.0748 0.1130 0.212 0.418 #> 4 0.214 0.0720 0.1110 0.206 0.377 #> 5 0.203 0.0697 0.0791 0.196 0.348 #> 6 0.198 0.0747 0.1030 0.180 0.360 #> 7 0.203 0.0638 0.1070 0.200 0.333 #> 8 0.191 0.0617 0.0827 0.188 0.299 #> 9 0.237 0.0985 0.0998 0.217 0.446 #> 10 0.238 0.0885 0.1200 0.234 0.406 #> 11 0.234 0.0792 0.0838 0.232 0.418 # a summary function returns the results as matrix summary(pred_cov) #> mean sd 2.5% 50% 97.5% #> 1 0.2046888 0.05103156 0.1233163 0.1989446 0.2908793 #> 2 0.1950595 0.04060381 0.1204606 0.1949910 0.2630753 #> 3 0.2160028 0.04120147 0.1538030 0.2089321 0.3022593 #> 4 0.2529856 0.04270467 0.1929258 0.2503303 0.3333643 #> 5 0.1969653 0.02764795 0.1544012 0.1980138 0.2518814 #> 6 0.1843000 0.04581607 0.1028620 0.1814753 0.2733072 #> 7 0.2383059 0.05162711 0.1487544 0.2326939 0.3438535 #> 8 0.1680299 0.03170941 0.1198606 0.1659361 0.2389757 #> 9 0.2410675 0.05211712 0.1538566 0.2392947 0.3450478 #> 10 0.1742228 0.03131481 0.1213062 0.1707167 0.2455262 #> 11 0.2426294 0.02309088 0.2061749 0.2463644 0.2792656 # obtain a prediction for new data with specific covariates pred_new <- predict(map, data.frame(country = \"CH\", study = 12)) pred_new #> Meta-Analytic-Predictive Prior Predictions #> Scale: response #> #> Summary: #> mean sd 2.5% 50% 97.5% #> 1 0.217 0.0793 0.0926 0.209 0.404 ## Recover user set sampling defaults options(.user_mc_options)"},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":null,"dir":"Reference","previous_headings":"","what":"Robustify Mixture Priors — robustify","title":"Robustify Mixture Priors — robustify","text":"Add non-informative component mixture prior.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Robustify Mixture Priors — robustify","text":"","code":"robustify(priormix, weight, mean, n = 1, ...) # S3 method for class 'betaMix' robustify(priormix, weight, mean, n = 1, ...) # S3 method for class 'gammaMix' robustify(priormix, weight, mean, n = 1, ...) # S3 method for class 'normMix' robustify(priormix, weight, mean, n = 1, ..., sigma)"},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Robustify Mixture Priors — robustify","text":"priormix orior (mixture conjugate distributions). weight weight given non-informative component (0 < weight < 1). mean mean non-informative component. recommended set parameter explicitly. n number observations non-informative prior corresponds , defaults 1. ... optional arguments ignored. sigma Sampling standard deviation case Normal mixtures.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Robustify Mixture Priors — robustify","text":"New mixture extra non-informative component named robust.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Robustify Mixture Priors — robustify","text":"recommended robustify informative priors derived gMAP using unit-information priors . protects prior-data conflict, see example Schmidli et al., 2015. procedure can used beta, gamma normal mixture priors. unit-information prior (see Kass Wasserman, 1995) corresponds prior represents observation n=1 null hypothesis. null problem dependent strongly recommend make use mean argument accordingly. See definition default mean. weights mixture priors rescaled (1-weight) non-informative prior assigned weight given.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"methods-by-class-","dir":"Reference","previous_headings":"","what":"Methods (by class)","title":"Robustify Mixture Priors — robustify","text":"robustify(betaMix): default mean set 1/2 represents difference occurrence rates one two outcomes. uniform Beta(1,1) appropriate practical applications, RBesT uses n+1 sample size default robust prior uniform instead Beta(1/2,1/2) strictly defined unit information prior case. robustify(gammaMix): default mean set mean prior mixture. strongly recommended explicitly set mean location null hypothesis. robustify(normMix): default mean set mean prior mixture. strongly recommended explicitly set mean location null hypothesis, often equal 0. also recommended explicitly set sampling standard deviation using sigma argument.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Robustify Mixture Priors — robustify","text":"Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan , Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors clinical trials historical control information. Biometrics 2014;70(4):1023-1032. Kass RE, Wasserman L Reference Bayesian Test Nested Hypotheses Relationship Schwarz Criterion J Amer Statist Assoc 1995; 90(431):928-934.","code":""},{"path":[]},{"path":"https://opensource.nibr.com/RBesT/reference/robustify.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Robustify Mixture Priors — robustify","text":"","code":"bmix <- mixbeta(inf1 = c(0.2, 8, 3), inf2 = c(0.8, 10, 2)) plot(bmix) rbmix <- robustify(bmix, weight = 0.1, mean = 0.5) rbmix #> Univariate beta mixture #> Mixture Components: #> inf1 inf2 robust #> w 0.18 0.72 0.10 #> a 8.00 10.00 1.00 #> b 3.00 2.00 1.00 plot(rbmix) gmnMix <- mixgamma(inf1 = c(0.2, 2, 3), inf2 = c(0.8, 2, 5), param = \"mn\") plot(gmnMix) rgmnMix <- robustify(gmnMix, weight = 0.1, mean = 2) rgmnMix #> Univariate Gamma mixture #> Mixture Components: #> inf1 inf2 robust #> w 0.18 0.72 0.10 #> a 6.00 10.00 2.00 #> b 3.00 5.00 1.00 plot(rgmnMix) nm <- mixnorm(inf1 = c(0.2, 0.5, 0.7), inf2 = c(0.8, 2, 1), sigma = 2) plot(nm) rnMix <- robustify(nm, weight = 0.1, mean = 0, sigma = 2) rnMix #> Univariate normal mixture #> Reference scale: 2 #> Mixture Components: #> inf1 inf2 robust #> w 0.18 0.72 0.10 #> m 0.50 2.00 0.00 #> s 0.70 1.00 2.00 plot(rnMix)"},{"path":"https://opensource.nibr.com/RBesT/reference/support.html","id":null,"dir":"Reference","previous_headings":"","what":"Support of Distributions — support","title":"Support of Distributions — support","text":"Returns support distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/support.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Support of Distributions — support","text":"","code":"support(mix)"},{"path":"https://opensource.nibr.com/RBesT/reference/support.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Support of Distributions — support","text":"mix Mixture distribution.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":null,"dir":"Reference","previous_headings":"","what":"Transplant. — transplant","title":"Transplant. — transplant","text":"Data set containing historical information standard treatment phase IV trial de novo transplant patients. primary outcome treament failure (binary).","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transplant. — transplant","text":"","code":"transplant"},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Transplant. — transplant","text":"data frame 4 rows 3 variables: study study n study size r number events","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/transplant.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Transplant. — transplant","text":"Neuenschwander B, Capkun-Niggli G, Branson M, Spiegelhalter DJ. Summarizing historical information controls clinical trials. Clin Trials. 2010; 7(1):5-18","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/uniroot_int.html","id":null,"dir":"Reference","previous_headings":"","what":"Find root of univariate function of integers — uniroot_int","title":"Find root of univariate function of integers — uniroot_int","text":"Uses bisectioning algorithm search give interval change sign returns integer closest 0.","code":""},{"path":"https://opensource.nibr.com/RBesT/reference/uniroot_int.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Find root of univariate function of integers — uniroot_int","text":"","code":"uniroot_int( f, interval, ..., f.lower = f(interval[1], ...), f.upper = f(interval[2], ...), maxIter = 1000 )"},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-18-1---january-20th-2025","dir":"Changelog","previous_headings":"","what":"RBesT 1.8-1 - January 20th, 2025","title":"RBesT 1.8-1 - January 20th, 2025","text":"CRAN release: 2025-01-21","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-8-1","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.8-1 - January 20th, 2025","text":"Fixed issue ess function beta gamma mixtures used inside lapply sapply.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-18-0---january-8th-2025","dir":"Changelog","previous_headings":"","what":"RBesT 1.8-0 - January 8th, 2025","title":"RBesT 1.8-0 - January 8th, 2025","text":"CRAN release: 2025-01-08","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-8-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.8-0 - January 8th, 2025","text":"Enable ESS calculation normal mixture densities used context standard one-parameter exponential family new family argument. example, can used calculate ESS normal mixture density representing logit transformed response scale. Reformat R sources using styler.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-8-0","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.8-0 - January 8th, 2025","text":"Correct boundary behavior BinaryExactCI function whenever responses non-responses observed. Fixes issue #21. Stabilize internal beta mixture information function, corrects unstable ESS ELIR computations. Addresses issue #22.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-4---november-21st-2024","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-4 - November 21st, 2024","title":"RBesT 1.7-4 - November 21st, 2024","text":"CRAN release: 2024-11-21","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-4 - November 21st, 2024","text":"Added mixstanvar automatic generation distribution functions allowing truncated priors brms mixtures Slight speed increase Stan model efficient construction likelihood. Also reducing object size gMAP objects avoiding store redundant variables. Upgraded testthat edition version 3.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-4","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-4 - November 21st, 2024","text":"Fix issue #18 ESS ELIR aborting whenever one mixture component zero weight. Fixed rare issue estimating ESS ELIR beta mixtures. calculation aborted due boundary issues now avoided. Avoid underflow beta-binomial distribution. Replace calls deprecated ggplot2::qplot respective calls ggplot2::ggplot. Use new array notation mixstanvar generated Stan code make generated Stan programs compatible Stan >= 2.33","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-3---january-2nd-2024","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-3 - January 2nd, 2024","title":"RBesT 1.7-3 - January 2nd, 2024","text":"CRAN release: 2024-01-08","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-3","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-3 - January 2nd, 2024","text":"Updated Stan model file syntax use new array syntax required Stan >=2.33. upgrades minimal Stan version 2.26. Moved vignettes articles decrease size R packages. Articles available package homepage.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-3","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-3 - January 2nd, 2024","text":"Added pngquant system requirements package requested CRAN.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-2---august-21st-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-2 - August 21st, 2023","title":"RBesT 1.7-2 - August 21st, 2023","text":"CRAN release: 2023-08-21","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-2 - August 21st, 2023","text":"Add unit tests mixstanvar function disabled integration tests CI/CD systems require significant resources due need compile Stan models. unit tests ensure things correct RBesT side things. Use new scheme roxygen2 document package documentation.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-2","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-2 - August 21st, 2023","text":"Make EM normal multivariate normal mixtures deterministic resulting density depend random seed longer, intended behavior. Note change may cause estimated normal / MVN mixtures numerically different compared previous version. estimated density (statistically) still .","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-1---august-8th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-1 - August 8th, 2023","title":"RBesT 1.7-1 - August 8th, 2023","text":"CRAN release: 2023-08-10","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-1","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-1 - August 8th, 2023","text":"Allow use mixture priors brms models new adapter function mixstanvar. Allow use named dimensions multivariate normal mixtures. Add experimental diagnostic plots mixture multivariate normal EM fits. subject changes future release user feedback welcome. Compress png plots vignettes saving ~40% file size package sources.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bugfixes-1-7-1","dir":"Changelog","previous_headings":"","what":"Bugfixes","title":"RBesT 1.7-1 - August 8th, 2023","text":"Fix issue plotting EM diagnostic debugging plots normal mixtures. Comply newer ggplot2 standards use aes_string.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-17-0---july-19th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.7-0 - July 19th, 2023","title":"RBesT 1.7-0 - July 19th, 2023","text":"CRAN release: 2023-07-20","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-7-0","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.7-0 - July 19th, 2023","text":"Implementation multivariate normal mixture support first version. includes density evaluation, basic summary functions multivariate normal EM fitting. Support yet complete densites, expanded upcoming releases. Change default option constrain_gt1 EM beta mixtures TRUE. default constrain fitted parameters beta mixture component greater unity required finite ESS elir calculations.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-7---june-26th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-7 - June 26th, 2023","title":"RBesT 1.6-7 - June 26th, 2023","text":"CRAN release: 2023-06-29","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-7","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-7 - June 26th, 2023","text":"resolve compilation source issues platforms triggered changes rstantools correct documentation difference distribution improve PoS co-data vignette","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-6---march-3rd-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-6 - March 3rd, 2023","title":"RBesT 1.6-6 - March 3rd, 2023","text":"CRAN release: 2023-03-03","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-6","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-6 - March 3rd, 2023","text":"ensure C++17 compatiblity per CRAN (triggers issue clang 16) fix links README.md now link new public pkgdown web-site","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-5---february-8th-2023","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-5 - February 8th, 2023","title":"RBesT 1.6-5 - February 8th, 2023","text":"CRAN release: 2023-02-10","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-6-5","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.6-5 - February 8th, 2023","text":"upon package load RBesT now report date release respective git commit hash used create sources package.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-5","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-5 - February 8th, 2023","text":"ensure predict new studies sample study specifc random effect per iteration . important MAP priors covariate effects (pooled studies).","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-4---august-5th-2022","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-4 - August 5th, 2022","title":"RBesT 1.6-4 - August 5th, 2022","text":"CRAN release: 2022-08-08","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"enhancements-1-6-4","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"RBesT 1.6-4 - August 5th, 2022","text":"use clustermq inplace batchtools SBC runs. Also use L’Ecuyer CMG random number gen SBC runs. expand introductory vignette plot ESS vs robust weight start using matrixStats speed EM algorithms & OCs avoid warning whenever 2S normal design expanded domain called repeatedly add mixdist plot plotting mixture resulting *mixfit call add warning message printing gMAP analysis Stan sampler issues due divergent transitions non-convergence indicated large Rhat","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"bug-fixes-1-6-4","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"RBesT 1.6-4 - August 5th, 2022","text":"mixture density evaluations (dmix) defined link function evaluate correctly, visible plotting mixtures (one component) link functions","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-3---november-23rd-2021","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-3 - November 23rd, 2021","title":"RBesT 1.6-3 - November 23rd, 2021","text":"CRAN release: 2021-11-24 update references JSS publication","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-2---september-3rd-2021","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-2 - September 3rd, 2021","title":"RBesT 1.6-2 - September 3rd, 2021","text":"CRAN release: 2021-09-03 link RcppParallel align new Stan requirements address CRAN comments","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-1---may-28th-2020","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-1 - May 28th, 2020","title":"RBesT 1.6-1 - May 28th, 2020","text":"CRAN release: 2020-05-28 stabilize elir ESS integration integrating per mixture component comply forthcoming stricter stanc3 Stan transpiler address warnings ggplot2 3.3.0","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-16-0---march-27th-2020","dir":"Changelog","previous_headings":"","what":"RBesT 1.6-0 - March 27th, 2020","title":"RBesT 1.6-0 - March 27th, 2020","text":"CRAN release: 2020-03-28 fix CI system issues fix issues normal decision2S_boundary boundaries grown add demo 2S OC simulation code time--event endpoint constant hazard assumption drop tidyverse dependency expand SBC checks include group specifc estimates stop setting ggplot2 default theme loading package. plots now use bayesplot theme can modified bayesplot_theme_* functions. See ?bayesplot::bayesplot_theme_get. correct transformation issue MAP variances vignette - thanks Ping Chen allow constrained fitting beta mixtures & b parameters greater 1. new default behavior function inform . informational message removed future release. introduced new mixecdf plot diagnostic EM fits","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-4---october-22nd-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-4 - October 22nd, 2019","title":"RBesT 1.5-4 - October 22nd, 2019","text":"CRAN release: 2019-10-23 Now really fix n2=0 case 2S design functions indirect comparisons Update package structure new rstantools 2.0 system","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-3---august-28th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-3 - August 28th, 2019","title":"RBesT 1.5-3 - August 28th, 2019","text":"CRAN release: 2019-08-28 Fix vignette MAP variances (missing definition)","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-2---august-28th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-2 - August 28th, 2019","title":"RBesT 1.5-2 - August 28th, 2019","text":"Speedup example run time Avoid use cat functions use message instead Replace dontrun examples donttest Require NOT_CRAN=true tests run","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-1---august-28th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-1 - August 28th, 2019","title":"RBesT 1.5-1 - August 28th, 2019","text":"Work around compiler warning clang fedora platform","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-15-0---august-15th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.5-0 - August 15th, 2019","title":"RBesT 1.5-0 - August 15th, 2019","text":"Fix indirect comparisons work normal/Poisson/binomial (inexact) allow n2=0 oc2S calls. Make mixture quantile function robust work flat mixture priors. Align ESS Morita calculations Neuenschwander B. et al., pre-print 2019; arXiv:1907.04185","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-14-0---july-27th-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.4-0 - July 27th, 2019","title":"RBesT 1.4-0 - July 27th, 2019","text":"CRAN release: 2019-06-27 Introduce elir ESS method new default ESS Allow sample prior predictive gMAP (argument prior_PD) Switch internally ab parametrized version EM beta algorithm","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-8---april-3nd-2019","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-8 - April 3nd, 2019","title":"RBesT 1.3-8 - April 3nd, 2019","text":"CRAN release: 2019-04-04 Use Simulation Based Calibration gMAP model qualification Improve covariate handling (naming data items) Speedup Stan model avoiding matrix-vector products many zeros Fix index issue differential discounting used covariates Make initialization EM algorithms robust Avoid special build hacks MacOS","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-7---november-16th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-7 - November 16th, 2018","title":"RBesT 1.3-7 - November 16th, 2018","text":"CRAN release: 2018-11-19 Address issue build process MacOS.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-6---november-14th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-6 - November 14th, 2018","title":"RBesT 1.3-6 - November 14th, 2018","text":"CRAN release: 2018-11-15 Re-create vignettes proper MCMC sampling. Automate R package build process using CI/CD.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-5---november-13th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-5 - November 13th, 2018","title":"RBesT 1.3-5 - November 13th, 2018","text":"CRAN release: 2018-11-14 Corrected 1.3-4 release notes include MAP variances vignette Make build process robust (updated src/Makevars{.win}) Added probability success interim vignette Added probability success co-data vignette","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-4---october-16th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-4 - October 16th, 2018","title":"RBesT 1.3-4 - October 16th, 2018","text":"CRAN release: 2018-10-17 Make package work rstan 2.18.1. Revert BetaBinomial implementation back R functions. Bugfix decision1S_boundary normal case extreme parameter configurations (fixes pos1S & oc1S well). Bugfix mixcombine plot normal mixtures without sigma defined. Bugfix repeated calls decision2S_boundary normal endpoint (fixes pos2S & oc2S well). Avoid use deprecated bayesplot function arguments whenever divergencies occured. (corrected) Added MAP variances vignette","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-3---february-2nd-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-3 - February 2nd, 2018","title":"RBesT 1.3-3 - February 2nd, 2018","text":"CRAN release: 2018-02-02 Change numerical equality testing use expect_equal (uses .equal internally accounting machine specifc tolerances) pass tests long double case. Numerical tolerances reverted back 1.3-1 settings.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-2---january-25th-2018","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-2 - January 25th, 2018","title":"RBesT 1.3-2 - January 25th, 2018","text":"CRAN release: 2018-01-25 Adjust numerical tolerances pass tests long double case","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-1---december-21st-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-1 - December 21st, 2017","title":"RBesT 1.3-1 - December 21st, 2017","text":"CRAN release: 2017-12-21 Add Trustees Columbia copyright respective files DESCRIPTION","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-13-0---december-21st-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.3-0 - December 21st, 2017","title":"RBesT 1.3-0 - December 21st, 2017","text":"Added probability success calculation 1+2 sample case. Added decision1+2S_boundary functions (deprecated use y2 argument oc functions) Added RBesT.integrate_args option greater control density integrations. Correct cumulative predictive beta mixtures return 0/1 --range values (instead leaving ). Deprecated functions oc1+2Sdecision replaced decision1+2S.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-3---august-21st-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-3 - August 21st, 2017","title":"RBesT 1.2-3 - August 21st, 2017","text":"CRAN release: 2017-08-21 Fix plotting procedures work bayesplot 1.3.0","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-2---july-12th-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-2 - July 12th, 2017","title":"RBesT 1.2-2 - July 12th, 2017","text":"CRAN release: 2017-07-12 speedup example runtimes.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-1---july-12th-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-1 - July 12th, 2017","title":"RBesT 1.2-1 - July 12th, 2017","text":"Compactify reference PDF manual. Introduce sampling arguments gMAP. Shorten runtime examples.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-12-0---july-3rd-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.2-0 - July 3rd, 2017","title":"RBesT 1.2-0 - July 3rd, 2017","text":"First CRAN release. Update documentation.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-11-0---may-15th-2017","dir":"Changelog","previous_headings":"","what":"RBesT 1.1-0 - May 15th, 2017","title":"RBesT 1.1-0 - May 15th, 2017","text":"Redesign reference scale handling normal case. Enable standard error sufficient statistic function. Introduced plotting options. Increased adapt_delta default set stepsize+max_treedepth default. Added RBesT.MC.{ncp, init, rescale} option. Corrections Poisson OC. pmixdiff function now integrates full support. Added argument enables designs based log-odds decisions relative risks. New graphical vignette new forest plot function. Use standard plotting package.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-10-0---march-10th-2016","dir":"Changelog","previous_headings":"","what":"RBesT 1.0-0 - March 10th, 2016","title":"RBesT 1.0-0 - March 10th, 2016","text":"Stabilize integration pmixdiff beta mixtures logit transform. Set default adapt_delta 0.975. Made RBesT compatible ggplot2 2.0. Allowed n2=0 function.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-09-2---oct-28th-2015","dir":"Changelog","previous_headings":"","what":"RBesT 0.9-2 - Oct 28th 2015","title":"RBesT 0.9-2 - Oct 28th 2015","text":"Corrected Poisson stratified estimates. Added warning divergent transitions. Added crohn dataset.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-09-1---sept-3rd-2015","dir":"Changelog","previous_headings":"","what":"RBesT 0.9-1 - Sept 3rd 2015","title":"RBesT 0.9-1 - Sept 3rd 2015","text":"Minor typo fixes.","code":""},{"path":"https://opensource.nibr.com/RBesT/news/index.html","id":"rbest-09-0---sept-1st-2015","dir":"Changelog","previous_headings":"","what":"RBesT 0.9-0 - Sept 1st 2015","title":"RBesT 0.9-0 - Sept 1st 2015","text":"First release.","code":""}]