# bcrd4r3: Blocked (Random) Cluster-level Regression Discontinuity... In cosa: Bound Constrained Optimal Sample Size Allocation

## Description

Use `mdes.bcrd4r3()` to calculate minimum detectable effect size, `power.bcrd4r3()` to calculate statistical power, and `cosa.bcrd4r3()` for bound constrained optimal sample size allocation (BCOSSA).

## Usage

 ``` 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``` ```mdes.bcrd4r3(score = NULL, dists = "normal", k1 = -6, k2 = 6, order = 1, interaction = FALSE, treat.lower = TRUE, cutoff = 0, p = NULL, power = .80, alpha = .05, two.tailed = TRUE, df = n4 - g4 - 1, rho2, rho3, rho4, omega4, r21 = 0, r22 = 0, r23 = 0, r2t4 = 0, g4 = 0, rate.tp = 1, rate.cc = 0, n1, n2, n3, n4) power.bcrd4r3(score = NULL, dists = "normal", k1 = -6, k2 = 6, order = 1, interaction = FALSE, treat.lower = TRUE, cutoff = 0, p = NULL, es = .25, alpha = .05, two.tailed = TRUE, df = n4 - g4 - 1, rho2, rho3, rho4, omega4, r21 = 0, r22 = 0, r23 = 0, r2t4 = 0, g4 = 0, rate.tp = 1, rate.cc = 0, n1, n2, n3, n4) cosa.bcrd4r3(score = NULL, dists = "normal", k1 = -6, k2 = 6, rhots = NULL, order = 1, interaction = FALSE, treat.lower = TRUE, cutoff = 0, p = NULL, cn1 = 0, cn2 = 0, cn3 = 0, cn4 = 0, cost = NULL, n1 = NULL, n2 = NULL, n3 = NULL, n4 = NULL, n0 = c(10, 3, 100, 5 + g4), 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, omega4, g4 = 0, r21 = 0, r22 = 0, r23 = 0, r2t4 = 0) ```

## Arguments

 `score` vector or list; an empirical score variable or an object with class 'score' returned from the `inspect.score()` function. `dists` character; distribution of the score variable, `"normal"` or `"uniform"`. By default, `dists = "normal"` specification implies a truncated normal distribution with `k1 = -6` and `k2 = 6`. `k1` left truncation point for (uncentered) empirical, truncated normal, or uniform distribution. Ignored when `rhots = 0` or `order = 0`. `k2` right truncation point for (uncentered) empirical, truncated normal, or uniform distribution. Ignored when `rhots = 0` or `order = 0`. `order` integer >= 0; order of polynomial functional form specification for the score variable. `interaction` logical; if `TRUE` polynomial specification interacts with the treatment variable. `rhots` obsolote; use `order = 0` to obtain results equivalent to random assignment designs. `treat.lower` logical; if `TRUE` units below the cutoff are treated. `cutoff` decision threshold. `p` proportion of level 3 units in the treatment condition. `power` statistical power (1 - β). `es` effect size (Cohen's d). `alpha` probability of type I error (α). `two.tailed` logical; `TRUE` for two-tailed hypothesis testing. `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). `omega4` ratio of the treatment effect variance between level 4 units to the variance in the outcome between level 4 units. `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. `r2t4` proportion of treatment effect variance between level 4 units explained by level 4 covariates. `rate.tp` treatment group participation rate. `rate.cc` control group crossover rate. `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 (blocks). `cn1` marginal costs per level 1 unit in treatment and control conditions (positional), e.g. `c(10, 5)`. `cn2` marginal costs per level 2 unit in treatment and control conditions (positional), e.g. `c(50, 20)`. `cn3` marginal costs per level 3 unit in treatment and control conditions (positional), e.g. `c(80, 50)`. `cn4` marginal cost per level 4 unit. `cost` total cost or budget. Ignored when `constrain = "power"` or `constrain = "es"`. `p0` starting value for `p` when `rhots = 0` and `p = NULL`. Starting value is replaced with the average when `p` is constrained by bounds. `n0` vector of starting values for `n1, n2, n3, n4` (positional). Starting values are replaced with the averages when sample sizes are constrained by bounds. `constrain` character; constrains one of the `"cost"`, `"power"`, or `"es"` at the specified value. `round` logical; `TRUE` for rounded BCOSSA solution. `max.power` logical; `TRUE` for maximizing the power rate instead of minimizing the variance. Applies when `constrain = "cost"`. `local.solver` subset of `c("LBFGS", "SLSQP")`.

## Value

 `parms` list of parameters used in the function. `df` degrees of freedom. `sse` standardized standard error. `cosa` BCOSSA solution. `mdes` minimum detectable effect size and (1 - α)% confidence limits. `power` statistical power (1 - β)

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```score.obj <- inspect.score(rnorm(1000), order = 1, interaction = FALSE, cutoff = 0, k1 = -1, k2 = 1) power.bcrd4r3(score.obj, es = 0.25, rho2 = .20, rho3 = .10, rho4 = .05, omega4 = .30, g4 = 0, r2t4 = 0, n1 = 20, n2 = 3, n3 = 20, n4 = 10) # minimum required number of level 3 units for each one of the level 4 block cosa.bcrd4r3(score.obj, es = 0.25, rho2 = .20, rho3 = .10, rho4 = .05, omega4 = .30, g4 = 0, r2t4 = 0, n1 = 20, n2 = 3, n3 = NULL, n4 = 10) ```

cosa documentation built on Nov. 21, 2021, 1:06 a.m.