| Title: | Bayesian Analysis for Multivariate Categorical Outcomes |
|---|---|
| Description: | Provides Bayesian methods for comparing groups on multiple binary outcomes. Includes basic tests using multivariate Bernoulli distributions, subgroup analysis via generalized linear models, and multilevel models for clustered data. For statistical underpinnings, see Kavelaars, Mulder, and Kaptein (2020) <doi:10.1177/0962280220922256>, Kavelaars, Mulder, and Kaptein (2024) <doi:10.1080/00273171.2024.2337340>, and Kavelaars, Mulder, and Kaptein (2023) <doi:10.1186/s12874-023-02034-z>. An interactive shiny app to perform sample size computations is available. |
| Authors: | Xynthia Kavelaars [aut, cre] (ORCID: <https://orcid.org/0000-0003-1600-3153>), Joris Mulder [ths] (ORCID: <https://orcid.org/0000-0001-7007-3086>), Maurits Kaptein [ths] (ORCID: <https://orcid.org/0000-0002-6316-7524>), Dutch Research Council [fnd] (Grant no. 406.18.505) |
| Maintainer: | Xynthia Kavelaars <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-05-22 09:00:54 UTC |
| Source: | https://github.com/xynthiakavelaars/bmco |
Provides Bayesian methods for comparing groups on multiple binary outcomes, including basic tests, regression adjustment, and multilevel models.
bmvb: Bayesian test using multivariate Bernoulli
bglm: Subgroup analysis using Bayesian logistic regression analysis
bglmm: Multilevel data using Bayesian multilevel logistic regression analysis
Maintainer: Xynthia Kavelaars [email protected] (ORCID)
Other contributors:
Joris Mulder (ORCID) [thesis advisor]
Maurits Kaptein (ORCID) [thesis advisor]
Dutch Research Council (Grant no. 406.18.505) [funder]
Kavelaars X, Mulder J, Kaptein M (2020). “Decision-making with multiple correlated binary outcomes in clinical trials.” Statistical Methods in Medical Research, 29(11), 3265–3277. doi:10.1177/0962280220922256.
Kavelaars X, Mulder J, Kaptein M (2024). “Bayesian Multivariate Logistic Regression for Superiority and Inferiority Decision-Making under Observable Treatment Heterogeneity.” Multivariate Behavioral Research, 59(4), 859–882. doi:10.1080/00273171.2024.2337340.
Kavelaars X, Mulder J, Kaptein M (2023). “Bayesian multilevel multivariate logistic regression for superiority decision-making under observable treatment heterogeneity.” BMC Medical Research Methodology, 23(1). doi:10.1186/s12874-023-02034-z.
Useful links:
Report bugs at https://github.com/XynthiaKavelaars/bmco/issues
Perform a Bayesian test for differences between two (sub)groups on multiple binary outcomes using multinomial logistic regression as described in Kavelaars et al. (2024).
bglm( data, grp, grp_a, grp_b, x_var, y_vars, x_method = c("Empirical", "Analytical", "Value"), x_def = c(-Inf, Inf), test = c("right_sided", "left_sided"), rule = c("All", "Any", "Comp"), w = NULL, b_mu0 = NULL, b_sigma0 = NULL, n_burn = 10000, n_it = 20000, n_thin = 1, n_chain = 2, start = c(0.5, 1), return_diagnostics = TRUE, return_diagnostic_plots = FALSE, return_samples = FALSE )bglm( data, grp, grp_a, grp_b, x_var, y_vars, x_method = c("Empirical", "Analytical", "Value"), x_def = c(-Inf, Inf), test = c("right_sided", "left_sided"), rule = c("All", "Any", "Comp"), w = NULL, b_mu0 = NULL, b_sigma0 = NULL, n_burn = 10000, n_it = 20000, n_thin = 1, n_chain = 2, start = c(0.5, 1), return_diagnostics = TRUE, return_diagnostic_plots = FALSE, return_samples = FALSE )
data |
Data frame containing the data. |
grp |
Character string. Name of the grouping variable (will be treated as factor). |
grp_a |
Value of grp indicating first group. |
grp_b |
Value of grp indicating second group. |
x_var |
Character string. Name of covariate variable (currently supports single continuous or binary covariate) |
y_vars |
Character vector. Names of outcome variables (currently supports 2 outcomes). |
x_method |
Character. Method for handling covariate: "Analytical" (numerical integration), "Empirical" (empirical marginalization), or "Value" (specific value). Default is "Empirical". |
x_def |
Numeric vector. Defines subpopulation: length-2 vector c(lower, upper) for "Analytical"/"Empirical", or scalar for "Value". Default is c(-Inf, Inf). |
test |
Character. Direction of test: "left_sided" for P(A>B) or "right_sided" for P(B>A). Default is "right_sided". |
rule |
Character. Decision rule: "All" (all outcomes favor hypothesis), "Any" (at least one outcome favors hypothesis), or "Comp" (weighted combination). Default is "All". |
w |
Numeric vector. Weights for compensatory rule. Only used if rule = "Comp". If NULL and rule = "Comp", equal weights are used. Default is NULL. |
b_mu0 |
Vector of prior means of fixed regression coefficients. Default is |
b_sigma0 |
Prior covariance matrix (PxP) of regression coefficients. Default is |
n_burn |
Integer. Number of burn-in iterations. Default is 10000. |
n_it |
Integer. Number of MCMC iterations. Default is 20000. |
n_thin |
Integer. Thinning interval. Default is 1. |
n_chain |
Integer. Number of MCMC chains to be sampled. Default is 2. |
start |
Numeric vector. Starting values for chains. Should have length |
return_diagnostics |
Logical. Return MCMC diagnostics? Default is TRUE. |
return_diagnostic_plots |
Logical. Should MCMC chains for diagnostic plots (traceplots, autocorrelation, density) be returned? Default is |
return_samples |
Logical. Should posterior samples be returned? Default is FALSE. |
An object of class bglm, a list containing:
A list with posterior means and standard deviations of
group probabilities (mean_a, mean_b, sd_a, sd_b),
as well as posterior means (b) and standard deviations (b_sd)
of the regression coefficients.
A list with group sample sizes (n_a, n_b).
A list with posterior mean differences (mean_delta),
posterior standard errors (se_delta), posterior probability of the
hypothesis (pop), and, if rule = "Comp", the weighted
difference (w_delta).
A list with prior specifications, test settings, group labels, covariate handling method, and subpopulation definition.
If diagnostics are requested, a list with MCMC diagnostic results for the regression coefficients.
If return_samples = TRUE, a list containing posterior
draws of theta_a, theta_b, delta, and regression
coefficients.
Kavelaars X, Mulder J, Kaptein M (2024). “Bayesian Multivariate Logistic Regression for Superiority and Inferiority Decision-Making under Observable Treatment Heterogeneity.” Multivariate Behavioral Research, 59(4), 859–882. doi:10.1080/00273171.2024.2337340.
# Example with simulated data # Generate data set.seed(123) n <- 100 data <- data.frame( group = rep(c("A", "B"), each = n/2), x = rnorm(n), stringsAsFactors = FALSE ) p1 <- p2 <- rep(NA, n) for (i in 1:n) { grpB <- ifelse(data$group[i] == "B", 1, 0) p1[i] <- plogis(-0.50 + 0.75 * grpB + 0.10 * data$x[i] + 0.20 * grpB * data$x[i]) p2[i] <- plogis(-0.50 + 0.80 * grpB + 0.05 * data$x[i] + 0.15 * grpB * data$x[i]) data$y1[i] <- rbinom(1, 1, p1[i]) data$y2[i] <- rbinom(1, 1, p2[i]) } # Analyze result <- bglm( data = data, grp = "group", grp_a = "A", grp_b = "B", x_var = "x", y_vars = c("y1", "y2"), x_method = "Empirical", x_def = c(-Inf, Inf), test = "right_sided", rule = "All", n_burn = 100, # Too low for proper MCMC sampling n_it = 500 # Too low for proper MCMC sampling ) print(result)# Example with simulated data # Generate data set.seed(123) n <- 100 data <- data.frame( group = rep(c("A", "B"), each = n/2), x = rnorm(n), stringsAsFactors = FALSE ) p1 <- p2 <- rep(NA, n) for (i in 1:n) { grpB <- ifelse(data$group[i] == "B", 1, 0) p1[i] <- plogis(-0.50 + 0.75 * grpB + 0.10 * data$x[i] + 0.20 * grpB * data$x[i]) p2[i] <- plogis(-0.50 + 0.80 * grpB + 0.05 * data$x[i] + 0.15 * grpB * data$x[i]) data$y1[i] <- rbinom(1, 1, p1[i]) data$y2[i] <- rbinom(1, 1, p2[i]) } # Analyze result <- bglm( data = data, grp = "group", grp_a = "A", grp_b = "B", x_var = "x", y_vars = c("y1", "y2"), x_method = "Empirical", x_def = c(-Inf, Inf), test = "right_sided", rule = "All", n_burn = 100, # Too low for proper MCMC sampling n_it = 500 # Too low for proper MCMC sampling ) print(result)
A simulated dataset representing a two-arm clinical trial with 200
subjects, one continuous covariate, and two binary outcomes. It serves
as the underlying data for bglm_fit and can be used to
illustrate bglm.
bglm_databglm_data
A data frame with 200 rows and 4 columns:
Character. Treatment arm: "placebo" (n = 100) or
"drug" (n = 100).
Numeric. Continuous covariate drawn from
.
Integer (0/1). First binary outcome.
Integer (0/1). Second binary outcome.
Data were generated with set.seed(2024) using logistic models:
where drug is 1 for the drug arm and 0 for placebo.
See data-raw/generate_examples.R for the full script.
head(bglm_data) table(bglm_data$group, bglm_data$y1)head(bglm_data) table(bglm_data$group, bglm_data$y1)
A fitted bglm object estimated on bglm_data.
Used in package examples and tests so that print, summary,
and plot examples run in well under 5 seconds without re-running
the MCMC sampler.
bglm_fitbglm_fit
An object of class bglm as returned by bglm.
See the Value section of bglm for a full
description of the list components. Key settings:
n_burn = 10000, n_it = 20000, n_chain = 2,
return_diagnostics = TRUE, return_samples = TRUE.
Generated with set.seed(2024).
See data-raw/generate_examples.R for the full reproducible script.
print(bglm_fit) summary(bglm_fit)print(bglm_fit) summary(bglm_fit)
Perform a Bayesian test for differences between two (sub)groups on multiple binary outcomes using multilevel multinomial logistic regression, as described in Kavelaars et al. (2023).
bglmm( data, grp, grp_a = NULL, grp_b = NULL, id_var, x_var, y_vars, x_method = c("Empirical", "Analytical", "Value"), x_def = c(-Inf, Inf), test = c("right_sided", "left_sided"), rule = c("All", "Any", "Comp"), w = NULL, n_burn = 10000, n_it = 50000, start = c(0.5, 1), fixed = NULL, random = NULL, b_mu0 = NULL, b_sigma0 = NULL, g_mu0 = NULL, g_sigma0 = NULL, nu0 = NULL, tau0 = NULL, n_chain = 2, return_thinned = TRUE, n_thin = 10, return_diagnostics = TRUE, return_diagnostic_plots = FALSE, return_samples = FALSE )bglmm( data, grp, grp_a = NULL, grp_b = NULL, id_var, x_var, y_vars, x_method = c("Empirical", "Analytical", "Value"), x_def = c(-Inf, Inf), test = c("right_sided", "left_sided"), rule = c("All", "Any", "Comp"), w = NULL, n_burn = 10000, n_it = 50000, start = c(0.5, 1), fixed = NULL, random = NULL, b_mu0 = NULL, b_sigma0 = NULL, g_mu0 = NULL, g_sigma0 = NULL, nu0 = NULL, tau0 = NULL, n_chain = 2, return_thinned = TRUE, n_thin = 10, return_diagnostics = TRUE, return_diagnostic_plots = FALSE, return_samples = FALSE )
data |
Data frame containing the data. |
grp |
Character string. Name of the grouping variable. |
grp_a |
Value of |
grp_b |
Value of |
id_var |
Character string. Name of cluster/ID variable. |
x_var |
Character string. Name of covariate variable. |
y_vars |
Character vector. Names of outcome variables (currently supports 2 outcomes). |
x_method |
Character. Method for handling covariate. Default is "Empirical". |
x_def |
Numeric. Defines subpopulation. Default is |
test |
Character. Direction of test: "left_sided" for P(A>B) or "right_sided" for P(B>A). Default is "right_sided". |
rule |
Character. Decision rule: "All" (all outcomes favor hypothesis), "Any" (at least one outcome favors hypothesis), or "Comp" (weighted combination). Default is "All". |
w |
Numeric vector. Weights for compensatory rule. Only used if rule = "Comp". If NULL and rule = "Comp", equal weights are used. Default is NULL. |
n_burn |
Integer. Number of burn-in iterations. Default is 10000. |
n_it |
Integer. Number of MCMC iterations. Default is 50000 (takes long running time!). |
start |
Numeric vector. Starting values for chains. Default is |
fixed |
Character vector. Names of fixed effect variables. Default is c(x_var, grp_x_var). |
random |
Character vector. Names of random effect variables. Default is c("Intercept", grp). |
b_mu0 |
Numeric vector. Prior means for fixed effects. Default is |
b_sigma0 |
Matrix. Prior covariance for fixed effects. Default is |
g_mu0 |
Numeric vector. Prior means for random effects. Default is |
g_sigma0 |
Matrix. Prior covariance for random effects. Default is |
nu0 |
Numeric. Prior degrees of freedom for inverse-Wishart. Default is |
tau0 |
Matrix. Prior scale matrix of dimension |
n_chain |
Integer. Number of MCMC chains. Default is 2. |
return_thinned |
Logical. Return thinned chains? Default is TRUE. |
n_thin |
Integer. Thinning interval. Default is 10. |
return_diagnostics |
Logical. Return MCMC diagnostics? Default is TRUE. |
return_diagnostic_plots |
Logical. Should MCMC chains for diagnostic plots (traceplots, autocorrelation, density) be returned? Default is |
return_samples |
Logical. Return posterior samples? Default is FALSE. |
An object of class bglmm, a list containing:
A list with posterior means and standard deviations of
group probabilities (mean_a, mean_b, sd_a, sd_b).
If estimated, posterior means and standard deviations of fixed effects
(b, b_sd) and random effects and variance components
(g, g_sd, tau, tau_sd) are included.
A list with group sample sizes (n_a, n_b)
and the number of clusters (J).
A list with posterior mean differences (mean_delta),
posterior standard errors (se_delta), posterior probability of the
hypothesis (pop), and, if rule = "Comp", the weighted
difference (w_delta).
A list with prior specifications, model structure (fixed and random effects), test settings, group labels, covariate handling method, and subpopulation definition.
If diagnostics are requested, a list with MCMC diagnostic results for fixed effects, random effects, and variance components.
If return_samples = TRUE, a list containing posterior
draws of group probabilities, differences, fixed effects, random effects,
and variance components (if applicable).
Kavelaars X, Mulder J, Kaptein M (2023). “Bayesian multilevel multivariate logistic regression for superiority decision-making under observable treatment heterogeneity.” BMC Medical Research Methodology, 23(1). doi:10.1186/s12874-023-02034-z.
# Example with simulated data # Generate data set.seed(123) J <- 20 # No. clusters nJ <- 15 # Sample size per cluster # Generate random intercepts uj_1 <- rnorm(J) uj_2 <- rnorm(J) data <- data.frame( id = factor(rep(1:J, each = nJ)), group = rep(rep(c("A", "B"), each = J/2), each = nJ), x = rnorm(J * nJ), stringsAsFactors = FALSE ) p1 <- p2 <- rep(NA, J * nJ) for (i in 1:(J * nJ)) { j <- as.numeric(data$id[i]) grpB <- ifelse(data$group[i] == "B", 1, 0) p1[i] <- plogis(-0.50 + 0.75 * grpB + 0.10 * data$x[i] + 0.20 * grpB * data$x[i] + uj_1[j]) p2[i] <- plogis(-0.50 + 0.80 * grpB + 0.05 * data$x[i] + 0.15 * grpB * data$x[i] + uj_2[j]) data$y1[i] <- rbinom(1, 1, p1[i]) data$y2[i] <- rbinom(1, 1, p2[i]) } # Analyze result <- bglmm( data = data, grp = "group", grp_a = "A", grp_b = "B", id_var = "id", x_var = "x", y_vars = c("y1", "y2"), x_method = "Empirical", x_def = c(-Inf, Inf), fixed = c("group", "x", "group_x"), random = c("Intercept"), # Random intercept model test = "right_sided", rule = "All", n_burn = 100, # Too low for proper MCMC sampling n_it = 500 # Too low for proper MCMC sampling ) print(result) # Warnings due to low number of MCMC iterations (n_burn and n_it)# Example with simulated data # Generate data set.seed(123) J <- 20 # No. clusters nJ <- 15 # Sample size per cluster # Generate random intercepts uj_1 <- rnorm(J) uj_2 <- rnorm(J) data <- data.frame( id = factor(rep(1:J, each = nJ)), group = rep(rep(c("A", "B"), each = J/2), each = nJ), x = rnorm(J * nJ), stringsAsFactors = FALSE ) p1 <- p2 <- rep(NA, J * nJ) for (i in 1:(J * nJ)) { j <- as.numeric(data$id[i]) grpB <- ifelse(data$group[i] == "B", 1, 0) p1[i] <- plogis(-0.50 + 0.75 * grpB + 0.10 * data$x[i] + 0.20 * grpB * data$x[i] + uj_1[j]) p2[i] <- plogis(-0.50 + 0.80 * grpB + 0.05 * data$x[i] + 0.15 * grpB * data$x[i] + uj_2[j]) data$y1[i] <- rbinom(1, 1, p1[i]) data$y2[i] <- rbinom(1, 1, p2[i]) } # Analyze result <- bglmm( data = data, grp = "group", grp_a = "A", grp_b = "B", id_var = "id", x_var = "x", y_vars = c("y1", "y2"), x_method = "Empirical", x_def = c(-Inf, Inf), fixed = c("group", "x", "group_x"), random = c("Intercept"), # Random intercept model test = "right_sided", rule = "All", n_burn = 100, # Too low for proper MCMC sampling n_it = 500 # Too low for proper MCMC sampling ) print(result) # Warnings due to low number of MCMC iterations (n_burn and n_it)
A simulated dataset representing a two-arm clinical trial with 300
subjects nested within 20 clusters (e.g., hospitals), one continuous
covariate, and two binary outcomes. It serves as the underlying data
for bglmm_fit and can be used to illustrate
bglmm.
bglmm_databglmm_data
A data frame with 300 rows and 5 columns:
Factor with 20 levels (1–20). Cluster
identifier (e.g., hospital). Each cluster contains 15 subjects.
Character. Treatment arm: "placebo" (clusters
1–10) or "drug" (clusters 11–20).
Numeric. Continuous covariate drawn from
.
Integer (0/1). First binary outcome.
Integer (0/1). Second binary outcome.
Data were generated with set.seed(2024) using logistic models
with cluster-specific random intercepts
:
where drug is 1 for the drug arm and 0 for placebo.
See data-raw/generate_examples.R for the full script.
head(bglmm_data) table(bglmm_data$group, bglmm_data$id)head(bglmm_data) table(bglmm_data$group, bglmm_data$id)
A fitted bglmm object estimated on bglmm_data.
Used in package examples and tests so that print, summary,
and plot examples run in well under 5 seconds without re-running
the MCMC sampler.
bglmm_fitbglmm_fit
An object of class bglmm as returned by bglmm.
See the Value section of bglmm for a full
description of the list components. Key settings:
n_burn = 10000, n_it = 50000, n_thin = 10,
n_chain = 2, return_diagnostics = TRUE,
return_samples = TRUE.
Generated with set.seed(2024).
See data-raw/generate_examples.R for the full reproducible script.
print(bglmm_fit) summary(bglmm_fit)print(bglmm_fit) summary(bglmm_fit)
Perform a Bayesian test for differences between two groups on multiple binary outcomes using a Multivariate Bernoulli distribution, as described in Kavelaars et al. (2020).
bmvb( data, grp, grp_a, grp_b, y_vars, test = c("right_sided", "left_sided"), rule = c("All", "Any", "Comp"), w = NULL, prior_a = 0.5, prior_b = 0.5, n_it = 10000, return_samples = FALSE )bmvb( data, grp, grp_a, grp_b, y_vars, test = c("right_sided", "left_sided"), rule = c("All", "Any", "Comp"), w = NULL, prior_a = 0.5, prior_b = 0.5, n_it = 10000, return_samples = FALSE )
data |
Data frame containing the data. |
grp |
Character string. Name of the grouping variable. |
grp_a |
Value of grp indicating first group. |
grp_b |
Value of grp indicating second group. |
y_vars |
Character vector. Names of outcome variables (currently supports 2 outcomes). |
test |
Character. Direction of test: "left_sided" for P(A>B) or "right_sided" for P(B>A). Default is "right_sided". |
rule |
Character. Decision rule: "All" (all outcomes favor hypothesis), "Any" (at least one outcome favors hypothesis), or "Comp" (weighted combination). Default is "All". |
w |
Numeric vector. Weights for compensatory rule. Only used if rule = "Comp". If NULL and rule = "Comp", equal weights are used. Default is NULL. |
prior_a |
Numeric. Prior hyperparameter (Dirichlet) for group A. Default is 0.5 (Jeffreys' prior) |
prior_b |
Numeric. Prior hyperparameter (Dirichlet) for group B. Default is 0.5 (Jeffreys' prior). |
n_it |
Integer. Number of MCMC iterations. Default is 10000. |
return_samples |
Logical. Should posterior samples be returned? Default is FALSE. |
An object of class bmvb, a list containing:
A list with posterior means (mean_a, mean_b)
and standard deviations (sd_a, sd_b) of the category probabilities
for both groups.
A list with group sample sizes (n_a, n_b).
A list with posterior mean differences (mean_delta),
posterior standard errors (se_delta), posterior probability of the
hypothesis (pop), and, if rule = "Comp", the weighted
difference (w_delta).
A list with test specifications, including the decision rule, test direction, group labels, and weights (if applicable).
If return_samples = TRUE, a list containing posterior
draws of theta_a, theta_b, and delta.
Kavelaars X, Mulder J, Kaptein M (2020). “Decision-making with multiple correlated binary outcomes in clinical trials.” Statistical Methods in Medical Research, 29(11), 3265–3277. doi:10.1177/0962280220922256.
# Example with simulated data # Generate data set.seed(123) data <- data.frame( treatment = rep(c("control", "drug"), each = 50), outcome1 = rbinom(100, 1, 0.5), outcome2 = rbinom(100, 1, 0.5) ) # Analyze result <- bmvb( data = data, grp = "treatment", grp_a = "control", grp_b = "drug", y_vars = c("outcome1", "outcome2"), n_it = 10000 ) print(result)# Example with simulated data # Generate data set.seed(123) data <- data.frame( treatment = rep(c("control", "drug"), each = 50), outcome1 = rbinom(100, 1, 0.5), outcome2 = rbinom(100, 1, 0.5) ) # Analyze result <- bmvb( data = data, grp = "treatment", grp_a = "control", grp_b = "drug", y_vars = c("outcome1", "outcome2"), n_it = 10000 ) print(result)
Plot Method for bglm Objects
## S3 method for class 'bglm' plot(x, type = "all", parameters = NULL, ...)## S3 method for class 'bglm' plot(x, type = "all", parameters = NULL, ...)
x |
A bglm object returned by bglm(). |
type |
Character. Type of plot: "trace", "density", "autocorr", or "all". Default is "all". |
parameters |
Character vector. Which parameters to plot. Default is NULL (all parameters). |
... |
Additional arguments passed to plotting functions. |
Invisibly returns NULL (plots are displayed).
# Uses the pre-computed example object shipped with the package. # Plot trace plots for the fixed-effect regression coefficients: plot(bglm_fit, type = "trace")# Uses the pre-computed example object shipped with the package. # Plot trace plots for the fixed-effect regression coefficients: plot(bglm_fit, type = "trace")
Plot Method for bglmm Objects
## S3 method for class 'bglmm' plot(x, type = "all", which = "fixed", parameters = NULL, ...)## S3 method for class 'bglmm' plot(x, type = "all", which = "fixed", parameters = NULL, ...)
x |
A bglmm object returned by bglmm(). |
type |
Character. Type of plot: "trace", "density", "autocorr", or "all". Default is "all". |
which |
Character. Which component to plot: "fixed" (b), "random" (g), "variance" (tau), or "all". Default is "fixed". |
parameters |
Character vector. Which parameters to plot. Default is NULL (all parameters). |
... |
Additional arguments passed to plotting functions. |
Invisibly returns NULL (plots are displayed).
# Uses the pre-computed example object shipped with the package. # Trace plots for the fixed-effect regression coefficients: plot(bglmm_fit, type = "trace", which = "fixed") # Trace plots for the random-effect variance components: plot(bglmm_fit, type = "trace", which = "variance")# Uses the pre-computed example object shipped with the package. # Trace plots for the fixed-effect regression coefficients: plot(bglmm_fit, type = "trace", which = "fixed") # Trace plots for the random-effect variance components: plot(bglmm_fit, type = "trace", which = "variance")
Print Method for bglm Objects
## S3 method for class 'bglm' print(x, digits = 3, ...)## S3 method for class 'bglm' print(x, digits = 3, ...)
x |
A bglm object. |
digits |
Number of digits to display. Default is 3. |
... |
Additional arguments (not used). |
Invisibly returns the input object.
# Uses the pre-computed example object shipped with the package: print(bglm_fit)# Uses the pre-computed example object shipped with the package: print(bglm_fit)
Print Method for bglmm Objects
## S3 method for class 'bglmm' print(x, digits = 3, ...)## S3 method for class 'bglmm' print(x, digits = 3, ...)
x |
A bglmm object. |
digits |
Number of digits to display. Default is 3. |
... |
Additional arguments (not used). |
Invisibly returns the input object.
# Uses the pre-computed example object shipped with the package: print(bglmm_fit)# Uses the pre-computed example object shipped with the package: print(bglmm_fit)
Print Method for bmvb Objects
## S3 method for class 'bmvb' print(x, digits = 3, ...)## S3 method for class 'bmvb' print(x, digits = 3, ...)
x |
A bmvb object. |
digits |
Number of digits to display. Default is 3. |
... |
Additional arguments (not used). |
Invisibly returns the input object.
set.seed(2024) trial_data <- data.frame( treatment = rep(c("placebo", "drug"), each = 50), y1 = rbinom(100, 1, rep(c(0.40, 0.60), each = 50)), y2 = rbinom(100, 1, rep(c(0.50, 0.70), each = 50)) ) fit <- bmvb( data = trial_data, grp = "treatment", grp_a = "placebo", grp_b = "drug", y_vars = c("y1", "y2"), n_it = 1000 ) print(fit)set.seed(2024) trial_data <- data.frame( treatment = rep(c("placebo", "drug"), each = 50), y1 = rbinom(100, 1, rep(c(0.40, 0.60), each = 50)), y2 = rbinom(100, 1, rep(c(0.50, 0.70), each = 50)) ) fit <- bmvb( data = trial_data, grp = "treatment", grp_a = "placebo", grp_b = "drug", y_vars = c("y1", "y2"), n_it = 1000 ) print(fit)
Print Method for summary.bglm Objects
## S3 method for class 'summary.bglm' print(x, digits = 3, ...)## S3 method for class 'summary.bglm' print(x, digits = 3, ...)
x |
A |
digits |
Number of digits to display. Default is |
... |
Additional arguments (not used). |
Invisibly returns x.
# Uses the pre-computed example object shipped with the package: print(summary(bglm_fit))# Uses the pre-computed example object shipped with the package: print(summary(bglm_fit))
Print Method for summary.bglmm Objects
## S3 method for class 'summary.bglmm' print(x, digits = 3, ...)## S3 method for class 'summary.bglmm' print(x, digits = 3, ...)
x |
A |
digits |
Number of digits to display. Default is |
... |
Additional arguments (not used). |
Invisibly returns x.
# Uses the pre-computed example object shipped with the package: print(summary(bglmm_fit))# Uses the pre-computed example object shipped with the package: print(summary(bglmm_fit))
Print Method for summary.bmvb Objects
## S3 method for class 'summary.bmvb' print(x, digits = 3, ...)## S3 method for class 'summary.bmvb' print(x, digits = 3, ...)
x |
A |
digits |
Number of digits to display. Default is |
... |
Additional arguments (not used). |
Invisibly returns x.
set.seed(2024) trial_data <- data.frame( treatment = rep(c("placebo", "drug"), each = 50), y1 = rbinom(100, 1, rep(c(0.40, 0.60), each = 50)), y2 = rbinom(100, 1, rep(c(0.50, 0.70), each = 50)) ) fit <- bmvb( data = trial_data, grp = "treatment", grp_a = "placebo", grp_b = "drug", y_vars = c("y1", "y2"), n_it = 1000, return_samples = TRUE ) print(summary(fit))set.seed(2024) trial_data <- data.frame( treatment = rep(c("placebo", "drug"), each = 50), y1 = rbinom(100, 1, rep(c(0.40, 0.60), each = 50)), y2 = rbinom(100, 1, rep(c(0.50, 0.70), each = 50)) ) fit <- bmvb( data = trial_data, grp = "treatment", grp_a = "placebo", grp_b = "drug", y_vars = c("y1", "y2"), n_it = 1000, return_samples = TRUE ) print(summary(fit))
Provides a comprehensive summary of a bglm analysis,
including the regression coefficient table, prior specification,
MCMC diagnostics (effective sample sizes and per
parameter), and, when the model was fitted with
return_samples = TRUE, credible intervals.
## S3 method for class 'bglm' summary(object, prob = 0.95, ...)## S3 method for class 'bglm' summary(object, prob = 0.95, ...)
object |
A |
prob |
Numeric. Coverage probability for credible intervals.
Default is |
... |
Additional arguments (not used). |
An object of class summary.bglm, a list containing:
Posterior means and SDs of group probabilities and regression coefficients.
Group sample sizes.
Posterior mean differences, SEs, and posterior probability.
Prior specification, test settings, and marginalization details.
If posterior samples are available: credible
interval matrices for theta_a, theta_b, and
delta.
If posterior samples are available: effective sample
sizes for theta_a, theta_b, and delta.
MCMC diagnostics for the regression coefficients
(effective sample sizes and ).
# Uses the pre-computed example object shipped with the package: summary(bglm_fit)# Uses the pre-computed example object shipped with the package: summary(bglm_fit)
Provides a comprehensive summary of a bglmm analysis,
including fixed and random effect tables, variance component estimates,
multilevel structure, and MCMC convergence diagnostics.
## S3 method for class 'bglmm' summary(object, prob = 0.95, ...)## S3 method for class 'bglmm' summary(object, prob = 0.95, ...)
object |
A |
prob |
Numeric. Coverage probability for credible intervals.
Default is |
... |
Additional arguments (not used). |
An object of class summary.bglmm, a list containing:
Posterior means and SDs of group probabilities, fixed effects, random effects, and variance components.
Group sample sizes and number of clusters.
Posterior mean differences, SEs, and posterior probability.
Prior specification, model structure, test settings, and marginalization details.
If posterior samples are available: credible
interval matrices for theta_a, theta_b, and
delta.
If posterior samples are available: effective sample
sizes for theta_a, theta_b, and delta.
MCMC convergence diagnostics (ESS, ,
MPSRF) for fixed effects, random effects, and variance components.
# Uses the pre-computed example object shipped with the package: summary(bglmm_fit)# Uses the pre-computed example object shipped with the package: summary(bglmm_fit)
Provides a comprehensive summary of a bmvb analysis.
When the model was fitted with return_samples = TRUE, credible
intervals and effective sample sizes are included.
## S3 method for class 'bmvb' summary(object, prob = 0.95, ...)## S3 method for class 'bmvb' summary(object, prob = 0.95, ...)
object |
A |
prob |
Numeric. Coverage probability for credible intervals.
Default is |
... |
Additional arguments (not used). |
An object of class summary.bmvb, a list containing all
fields of object plus:
If posterior samples are available: a list
with prob and credible interval matrices for theta_a,
theta_b, and delta.
If posterior samples are available: a list with
effective sample sizes for theta_a, theta_b, and
delta.
set.seed(2024) trial_data <- data.frame( treatment = rep(c("placebo", "drug"), each = 50), y1 = rbinom(100, 1, rep(c(0.40, 0.60), each = 50)), y2 = rbinom(100, 1, rep(c(0.50, 0.70), each = 50)) ) fit <- bmvb( data = trial_data, grp = "treatment", grp_a = "placebo", grp_b = "drug", y_vars = c("y1", "y2"), n_it = 1000, return_samples = TRUE ) summary(fit)set.seed(2024) trial_data <- data.frame( treatment = rep(c("placebo", "drug"), each = 50), y1 = rbinom(100, 1, rep(c(0.40, 0.60), each = 50)), y2 = rbinom(100, 1, rep(c(0.50, 0.70), each = 50)) ) fit <- bmvb( data = trial_data, grp = "treatment", grp_a = "placebo", grp_b = "drug", y_vars = c("y1", "y2"), n_it = 1000, return_samples = TRUE ) summary(fit)