Title: | Bayesian Multigroup Equivalence Testing |
---|---|
Description: | Calculates the necessary quantities to perform Bayesian multigroup equivalence testing. Currently the package includes the Bayesian models and equivalence criteria outlined in Pourmohamad and Lee (2023) <doi:10.1002/sta4.645>, but more models and equivalence testing features may be added over time. |
Authors: | Tony Pourmohamad [aut, cre] |
Maintainer: | Tony Pourmohamad <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-04 03:02:36 UTC |
Source: | https://github.com/tpourmohamad/bmet |
Function creates a contrast matrix for all pairwise comparisons
apc(ngroups, labs = NULL)
apc(ngroups, labs = NULL)
ngroups |
A positive integer greater than 1 denoting the number of groups |
labs |
A vector of groups labels with length equal to |
The function returns a matrix of all pairwise contrasts.
### A contrast matrix based on all pairwise contrasts of 5 groups apc(5) ### Adding group labels apc(5, labs = paste("Group", 1:5, sep = " "))
### A contrast matrix based on all pairwise contrasts of 5 groups apc(5) ### Adding group labels apc(5, labs = paste("Group", 1:5, sep = " "))
Function provides the necessary tools to carry out Bayesian multigroup equivalence testing based on sampling of the posterior distribution. The function returns posterior samples of the average differences amongst groups, as well as posterior samples of group variances.
bet(values, groups, em, A, B = 10000, test = "mean")
bet(values, groups, em, A, B = 10000, test = "mean")
values |
A vector of measurements sorted in the same order as the |
groups |
A vector of groups labels corresponding to the individual measurements in the |
em |
A c x 2 matrix of lower and upper equivalence margins. Here, c is the number of pairwise comparisons of interest. |
A |
A c x k matrix of pairwise contrasts. Here, k is the number of groups, i.e., |
B |
A positive integer specifying the number of posterior samples to draw. By default |
test |
Setting this to anything other than "mean" tells the function to not calculate the posterior probability that the average differences fall within the equivalence margins (applicable when testing equivalence based on something other than just average differences). |
The function returns a list object containing the following:
prob: The posterior probability that the average differences fall within the equivalence margins. Only returned if test == "mean"
.
delta: A B x c matrix of posterior samples of the average difference for each pairwise comparison of interest.
sigma2: A B x k matrix of posterior samples of the variance for each group.
Pourmohamad, T. and Lee, H.K.H. (2023). Equivalence Testing for Multiple Groups. Stat, e645.
### Multigroup equivalence test for A vs. B and A vs. C values <- rnorm(75) groups <- rep(LETTERS[1:3], each = 25) mad1 <- 0.65 # The equivalence margin for A vs. B mad2 <- 0.65 # The equivalence margin for A vs. C mads <- c(mad1, mad2) mads <- cbind(-mads, mads) A <- apc(3) A <- A[1:2, ] out <- bet(values, groups, mads, A, B = 10000) out$prob # The posterior probability that the average # differences fall within the equivalence margins
### Multigroup equivalence test for A vs. B and A vs. C values <- rnorm(75) groups <- rep(LETTERS[1:3], each = 25) mad1 <- 0.65 # The equivalence margin for A vs. B mad2 <- 0.65 # The equivalence margin for A vs. C mads <- c(mad1, mad2) mads <- cbind(-mads, mads) A <- apc(3) A <- A[1:2, ] out <- bet(values, groups, mads, A, B = 10000) out$prob # The posterior probability that the average # differences fall within the equivalence margins
Function provides the necessary tools to carry out Bayesian multigroup equivalence testing based on sampling of the posterior predictive distribution. The function returns posterior predictive samples of future differences amongst groups.
betpp(values, groups, em, A, B = 10000)
betpp(values, groups, em, A, B = 10000)
values |
A vector of measurements sorted in the same order as the |
groups |
A vector of groups labels corresponding to the individual measurements in the |
em |
A c x 2 matrix of lower and upper equivalence margins. Here, c is the number of pairwise comparisons of interest. |
A |
A c x k matrix of pairwise contrasts. Here, k is the number of groups, i.e., |
B |
A positive integer specifying the number of posterior predictive samples to draw. By default |
The function returns a list object containing the following:
prob: The probability that future differences fall within the equivalence margins.
delta: A B x c matrix of posterior predictive samples of future differences for each pairwise comparison of interest.
Pourmohamad, T. and Lee, H.K.H. (2023). Equivalence Testing for Multiple Groups. Stat, e645.
### Multigroup equivalence test for A vs. B and A vs. C values <- rnorm(75) groups <- rep(LETTERS[1:3], each = 25) mad1 <- 0.65 # The equivalence margin for A vs. B mad2 <- 0.65 # The equivalence margin for A vs. C mads <- c(mad1, mad2) mads <- cbind(-mads, mads) A <- apc(3) A <- A[1:2, ] out <- betpp(values, groups, mads, A, B = 10000) out$prob # The probability that future differences # fall within the equivalence margins
### Multigroup equivalence test for A vs. B and A vs. C values <- rnorm(75) groups <- rep(LETTERS[1:3], each = 25) mad1 <- 0.65 # The equivalence margin for A vs. B mad2 <- 0.65 # The equivalence margin for A vs. C mads <- c(mad1, mad2) mads <- cbind(-mads, mads) A <- apc(3) A <- A[1:2, ] out <- betpp(values, groups, mads, A, B = 10000) out$prob # The probability that future differences # fall within the equivalence margins