View source: R/bayes_sim_unbalanced.R
bayes_sim_unbalanced | R Documentation |
Approximates the Bayesian assurance of attaining u'β > C for unbalanced study designs through Monte Carlo sampling. See Argument descriptions for more detail.
bayes_sim_unbalanced( n1, n2, repeats = 1, u, C, Xn = NULL, Vn = NULL, Vbeta_d, Vbeta_a_inv, sigsq, mu_beta_d, mu_beta_a, alt, alpha, mc_iter, surface_plot = TRUE )
n1 |
first sample size (vector or scalar). |
n2 |
second sample size (vector or scalar). |
repeats |
an positive integer specifying number of times to repeat
|
u |
a scalar or vector to evaluate u'β > C, where β is an unknown parameter that is to be estimated.
Default setting is |
C |
constant value to be compared to when evaluating u'β > C |
Xn |
design matrix that characterizes where the data is to be generated from. This is specifically designed under the normal linear regression model yn = Xnβ + ε, ε ~ N(0, σ^2 Vn). When set to |
Vn |
a correlation matrix for the marginal distribution of the
sample data |
Vbeta_d |
correlation matrix that helps describe the prior information on β in the design stage |
Vbeta_a_inv |
inverse-correlation matrix that helps describe the prior information on β in the analysis stage |
sigsq |
a known and fixed constant preceding all correlation matrices
|
mu_beta_d |
design stage mean |
mu_beta_a |
analysis stage mean |
alt |
specifies alternative test case, where alt = "greater" tests if u'β > C, alt = "less" tests if u'β < C, and alt = "two.sided" performs a two-sided test. By default, alt = "greater". |
alpha |
significance level |
mc_iter |
number of MC samples evaluated under the analysis objective |
surface_plot |
when set to |
a list of objects corresponding to the assurance approximations
assurance_table: table of sample size and corresponding assurance values
contourplot: contour map of assurance values
mc_samples: number of Monte Carlo samples that were generated and evaluated
## Example 1 ## Sample size vectors are passed in for n1 and n2 to evaluate ## assurance. n1 <- seq(20, 75, 5) n2 <- seq(50, 160, 10) assur_out <- bayes_sim_unbalanced(n1 = n1, n2 = n2, repeats = 1, u = c(1, -1), C = 0, Xn = NULL, Vbeta_d = matrix(c(50, 0, 0, 10),nrow = 2, ncol = 2), Vbeta_a_inv = matrix(rep(0, 4), nrow = 2, ncol = 2), Vn = NULL, sigsq = 100, mu_beta_d = c(1.17, 1.25), mu_beta_a = c(0, 0), alt = "two.sided", alpha = 0.05, mc_iter = 1000, surface_plot = FALSE) assur_out$assurance_table ## Example 2 ## We can produce a contour plot that evaluates unique combinations of n1 ## and n2 simply by setting `surfaceplot = TRUE`. n1 <- seq(20, 75, 5) n2 <- seq(50, 160, 10) assur_out <- bayes_sim_unbalanced(n1 = n1, n2 = n2, repeats = 1, u = c(1, -1), C = 0, Xn = NULL, Vbeta_d = matrix(c(50, 0, 0, 10), nrow = 2, ncol = 2), Vbeta_a_inv = matrix(rep(0, 4), nrow = 2, ncol = 2), Vn = NULL, sigsq = 100, mu_beta_d = c(1.17, 1.25), mu_beta_a = c(0, 0), alt = "two.sided", alpha = 0.05, mc_iter = 1000, surface_plot = TRUE) assur_out$assurance_table assur_out$contourplot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.