Description Usage Arguments Value Examples

Use `mdes.crd4()`

to calculate minimum detectable effect size, `power.crd4()`

to calculate statistical power, and `cosa.crd4()`

for constrained optimal sample allocation.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
mdes.crd4(power = .80, alpha = .05, two.tailed = TRUE, df = n4 - g4 - order - 2,
score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal",
rho2, rho3, rho4, r21 = 0, r22 = 0, r23 = 0, r24 = 0,
g4 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2, n3, n4)
power.crd4(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal",
es = .25, alpha = .05, two.tailed = TRUE, df = n4 - g4 - order - 2,
rho2, rho3, rho4, r21 = 0, r22 = 0, r23 = 0, r24 = 0,
g4 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2, n3, n4)
cosa.crd4(score = NULL, order = 2, rhots = NULL,
k1 = -6, k2 = 6, dists = "normal",
cn1 = 0, cn2 = 0, cn3 = 0, cn4 = 0, cost = NULL,
n1 = NULL, n2 = NULL, n3 = NULL, n4 = NULL, p = NULL,
n0 = c(10, 3, 100, 5 + g4 + order), p0 = .499,
constrain = "power", round = TRUE, max.power = FALSE,
local.solver = c("LBFGS", "SLSQP"),
power = .80, es = .25, alpha = .05, two.tailed = TRUE,
rho2, rho3, rho4, g4 = 0, r21 = 0, r22 = 0, r23 = 0, r24 = 0)
``` |

`score` |
list; an object with class 'score' returned from |

`order` |
integer; order of functional form for the score variable, 0 for corresponding random assignment designs, 1 for RD design with linear score variable, 2 for RD design with linear + quadratic score variable |

`rhots` |
correlation between the treatment and the scoring variable. Specify |

`k1` |
numeric; left truncation point for truncated normal dist., or lower bound for uniform dist., ignored when |

`k2` |
numeric; right truncation point for truncated normal dist., or upper bound for uniform dist., ignored when |

`dists` |
character; distribution of the score variable, |

`power` |
statistical power (1 - |

`es` |
effect size (Cohen's d). |

`alpha` |
probability of type I error ( |

`two.tailed` |
logical; |

`df` |
degrees of freedom. |

`rho2` |
proportion of variance in the outcome between level 2 units (unconditional ICC2). |

`rho3` |
proportion of variance in the outcome between level 3 units (unconditional ICC3). |

`rho4` |
proportion of variance in the outcome between level 4 units (unconditional ICC4). |

`g4` |
number of covariates at level 4. |

`r21` |
proportion of level 1 variance in the outcome explained by level 1 covariates. |

`r22` |
proportion of level 2 variance in the outcome explained by level 2 covariates. |

`r23` |
proportion of level 3 variance in the outcome explained by level 3 covariates. |

`r24` |
proportion of level 4 variance in the outcome explained by level 4 covariates. |

`rate.tp` |
treatment group participation rate. |

`rate.cc` |
control group crossover rate. |

`p` |
proportion of level 4 units in treatment condition. |

`n1` |
average number of level 1 units per level 2 unit. |

`n2` |
average number of level 2 units per level 3 unit. |

`n3` |
average number of level 3 units per level 4 unit. |

`n4` |
number of level 4 units. |

`cn1` |
marginal cost per level 1 unit in treatment and control conditions, e.g. |

`cn2` |
marginal cost per level 2 unit in treatment and control conditions, e.g. |

`cn3` |
marginal cost per level 3 unit in treatment and control conditions, e.g. |

`cn4` |
marginal cost per level 4 unit in treatment and control conditions, e.g. |

`cost` |
total cost or budget. |

`p0` |
starting value for |

`n0` |
vector of starting values for |

`constrain` |
character; |

`round` |
logical; |

`max.power` |
logical; |

`local.solver` |
subset of |

`parms` |
list of parameters used in the function. |

`df` |
degrees of freedom. |

`sse` |
standardized standard error. |

`cosa` |
constrained optimal sample allocation. |

`mdes` |
minimum detectable effect size and (1 - |

`power` |
statistical power (1 - |

1 2 3 4 5 6 7 8 9 10 11 12 | ```
score.obj <- inspect.score(rnorm(10000), cutoff = 0)
power.crd4(score.obj, order = 2,
es = .25, rho2 = .20, rho3 = .10, rho4 = .05,
g4 = 0, r24 = 0, n1 = 20, n2 = 3, n3 = 20, n4 = 20)
# optimal combination of sample sizes for level 1, level 3 and level 4
# that produce power = .80 (given range restriction for level 1 sample size)
cosa.crd4(score.obj, order = 2,
constrain = "power", power = .80,
es = .25, rho2 = .20, rho3 = .10, rho4 = .05,
g4 = 0, r24 = 0,
n1 = c(20, 60), n2 = 2, n3 = NULL, n4 = NULL)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.