Description Usage Arguments Details Value See Also Examples
Helps specifying unequal cluster sizes with study_parameters
1 | unequal_clusters(..., func = NULL, trunc = 1, replace = 1)
|
... |
Any number of separate numeric arguments specifying each cluster's size |
func |
A function that generates cluster sizes, used instead of |
trunc |
Cutoff for values generated by |
replace |
Indicates what value to replace cluster sizes less than |
If func
is used together with a function that generates random draws, e.g.
rnorm
or rpois
, then cluster sizes (and possibly the number of clusters),
will be treated as a random variable. The expected power is then reported by averaging over
multiple realizations of the random variables.
Unless per_treatment
is used, then the same realization of random cluster sizes
will be used in both groups. To use independent realizations from the same distribution for
each treatment group, simply combine the unequal_clusters
with per_treatment
.
An object of type 'plcp_unequal_clusters'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | library(dplyr)
n2 <- unequal_clusters(5, 10, 15, 40)
p <- study_parameters(n1 = 11,
n2 = n2,
n3 = 6,
T_end = 10,
icc_pre_subject = 0.5,
icc_pre_cluster = 0,
sigma_error = 1,
var_ratio = 0.03,
icc_slope = 0.05,
cohend = -0.8)
# verify cluster sizes
d <- simulate_data(p)
d %>%
filter(time == 0) %>%
group_by(treatment, cluster) %>%
summarise(n = n())
# Poisson distributed cluster sizes, same in both groups
n2 <- unequal_clusters(func = rpois(n = 5, lambda = 5))
p <- study_parameters(n1 = 11,
n2 = n2,
T_end = 10,
icc_pre_subject = 0.5,
icc_pre_cluster = 0,
sigma_error = 1,
var_ratio = 0.03,
icc_slope = 0.05,
cohend = -0.8)
# Independent draws from same dist
n2 <- unequal_clusters(func = rpois(n = 5, lambda = 5))
p <- study_parameters(n1 = 11,
n2 = per_treatment(n2, n2),
T_end = 10,
icc_pre_subject = 0.5,
icc_pre_cluster = 0,
sigma_error = 1,
var_ratio = 0.03,
icc_slope = 0.05,
cohend = -0.8)
# Use per_treatment() to specify per treatment ------------------------------
n2 <- per_treatment(unequal_clusters(2, 2, 2, 2, 3, 4, 5),
unequal_clusters(10, 15))
p <- study_parameters(n1 = 11,
n2 = n2,
n3 = 3,
T_end = 10,
icc_pre_subject = 0.5,
icc_pre_cluster = 0,
var_ratio = 0.03,
icc_slope = 0.05,
cohend = -0.8)
# verify cluster sizes
d <- simulate_data(p)
d %>%
filter(time == 0) %>%
group_by(treatment, cluster) %>%
summarise(n = n())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.