mv_ln <- mvSim(
dists = list(
rlnorm = list(meanlog = log(130), sdlog = log(1.2)),
rlnorm = list(meanlog = log(100), sdlog = log(1.3))
),
n_samples = 30
)
# lognormal mv
ln_mv_ex <- conjugate(
s1 = mv_ln[1:30, -1], s2 = mv_ln[31:60, -1], method = "lognormal",
priors = list(mu = 5, sd = 2),
rope_range = c(-40, 40), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal", support = NULL
)
# lognormal sv
ln_sv_ex <- conjugate(
s1 = rlnorm(100, log(130), log(1.3)), s2 = rlnorm(100, log(100), log(1.6)),
method = "lognormal",
priors = list(mu = 5, sd = 2),
rope_range = NULL, rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal", support = NULL
)
# Z test mv example
mv_gauss <- mvSim(
dists = list(
rnorm = list(mean = 50, sd = 10),
rnorm = list(mean = 60, sd = 12)
),
n_samples = 30
)
gauss_mv_ex <- conjugate(
s1 = mv_gauss[1:30, -1], s2 = mv_gauss[31:60, -1], method = "gaussian",
priors = list(mu = 30, sd = 10),
rope_range = c(-25, 25), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal", support = NULL
)
# T test sv example with two different priors
gaussianMeans_sv_ex <- conjugate(
s1 = rnorm(10, 50, 10), s2 = rnorm(10, 60, 12), method = "t",
priors = list(list(mu = 40, sd = 10), list(mu = 45, sd = 8)),
rope_range = c(-5, 8), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal", support = NULL
)
# beta mv example
set.seed(123)
mv_beta <- mvSim(
dists = list(
rbeta = list(shape1 = 5, shape2 = 8),
rbeta = list(shape1 = 10, shape2 = 10)
),
n_samples = c(30, 20)
)
beta_mv_ex <- conjugate(
s1 = mv_beta[1:30, -1], s2 = mv_beta[31:50, -1], method = "beta",
priors = list(a = 0.5, b = 0.5),
rope_range = c(-0.1, 0.1), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal",
bayes_factor = 0.5 # note this may not be reasonable with these priors
)
# beta sv example
beta_sv_ex <- conjugate(
s1 = rbeta(20, 5, 5), s2 = rbeta(20, 8, 5), method = "beta",
priors = list(a = 0.5, b = 0.5),
rope_range = c(-0.1, 0.1), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal",
bayes_factor = c(0.5, 0.75) # note this may not be reasonable with these priors
)
# binomial sv example
# note that specifying trials = 20 would also work
# and the number of trials will be recycled to the length of successes
binomial_sv_ex <- conjugate(
s1 = list(successes = c(15, 14, 16, 11), trials = c(20, 20, 20, 20)),
s2 = list(successes = c(7, 8, 10, 5), trials = c(20, 20, 20, 20)), method = "binomial",
priors = list(a = 0.5, b = 0.5),
rope_range = c(-0.1, 0.1), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal"
)
# poisson sv example
poisson_sv_ex <- conjugate(
s1 = rpois(20, 10), s2 = rpois(20, 8), method = "poisson",
priors = list(a = 0.5, b = 0.5),
rope_range = c(-1, 1), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal"
)
# negative binomial sv example
# knowing r (required number of successes) is an important caveat for this method.
# in the current implementation we suggest using the poisson method for data such as leaf counts
negbin_sv_ex <- conjugate(
s1 = rnbinom(20, 10, 0.5), s2 = rnbinom(20, 10, 0.25), method = "negbin",
priors = list(r = 10, a = 0.5, b = 0.5),
rope_range = c(-1, 1), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal"
)
# von mises mv example
mv_gauss <- mvSim(
dists = list(
rnorm = list(mean = 50, sd = 10),
rnorm = list(mean = 60, sd = 12)
),
n_samples = c(30, 40)
)
vm1_ex <- conjugate(
s1 = mv_gauss[1:30, -1],
s2 = mv_gauss[31:70, -1],
method = "vonmises",
priors = list(mu = 45, kappa = 1, boundary = c(0, 180), known_kappa = 1, n = 1),
rope_range = c(-1, 1), rope_ci = 0.89,
cred.int.level = 0.89, hypothesis = "equal"
)
# von mises 2 sv example
vm2_ex <- conjugate(
s1 = brms::rvon_mises(10, 2, 2),
s2 = brms::rvon_mises(15, 3, 3),
method = "vonmises2",
priors = list(mu = 0, kappa = 0.5, boundary = c(-pi, pi), n = 1),
cred.int.level = 0.95
)
Run the code above in your browser using DataLab