Learn R Programming

cosa (version 1.2.0)

bcrd4r2: Blocked Cluster-level Regression Discontinuity (Four-level Design, Discontinuity at Level 2)

Description

Use mdes.bcrd4r2() to calculate minimum detectable effect size, power.bcrd4r2() to calculate statistical power, and use cosa.bcrd4r2() for constrained optimal sample allocation.

Usage

cosa.bcrd4r2(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), p0 = .499, constrain = "power",
             round = TRUE, max.power = FALSE,
             local.solver = c("LBFGS", "SLSQP", "MMA", "COBYLA"),
             rhots = NULL, k1 = -6, k2 = 6, dists = "normal",
             power = .80, es = .25, alpha = .05, two.tailed = TRUE,
             rho2, rho3, rho4, omega3, omega4,
             g4 = 0, r21 = 0, r22 = 0, r2t3 = 0, r2t4 = 0)

mdes.bcrd4r2(power = .80, alpha = .05, two.tailed = TRUE, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", rho2, rho3, rho4, omega3, omega4, r21 = 0, r22 = 0, r2t3 = 0, r2t4 = 0, g4 = 0, p = .50, n1, n2, n3, n4)

power.bcrd4r2(es = .25, alpha = .05, two.tailed = TRUE, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", rho2, rho3, rho4, omega3, omega4, r21 = 0, r22 = 0, r2t3 = 0, r2t4 = 0, g4 = 0, p = .50, n1, n2, n3, n4)

Arguments

cn1

marginal cost per level 1 unit in treatment and control conditions.

cn2

marginal cost per level 2 unit in treatment and control conditions.

cn3

marginal cost per level 3 unit.

cn4

marginal cost per level 4 unit.

cost

total cost or budget.

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.

p

proportion of level 2 units in treatment condition.

n0

vector of starting values for n1, n2, n3, n4 (positional). Starting values are replaced with averages when sample sizes are constrained by bounds.

p0

starting value for p when rhots = 0 and p = NULL. Starting value is replaced with average when p is constrained by bounds.

power

statistical power (1 - \(\beta\)).

es

effect size (Cohen's d).

alpha

probability of type I error (\(\alpha\)).

two.tailed

logical; TRUE for two-tailed hypothesis testing.

constrain

character; "cost", "power", or "mdes".

round

logical; TRUE for rounded COSA solution.

max.power

logical; TRUE for maximizing power instead of minimizing variance.

local.solver

subset of c("LBFGS", "SLSQP", "MMA", "COBYLA").

rhots

correlation between the treatment and the scoring variable. Specify rhots = 0 to obtain results equivalent to random assignment designs.

k1

left truncation point (in standard deviation units from full normal distribution mean), ignored when rhots is not NULL or dists = "uniform".

k2

right truncation point (in standard deviation units from full normal distribution mean), ignored when rhots is not NULL or dists = "uniform".

dists

distribution of the scoring variable; "normal" or "uniform". By default, dists = "normal" specification implies a truncated normal distribution with k1 = -6 and k2 = 6.

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).

omega3

ratio of the treatment effect variance between level 3 units to the variance in the outcome between level 3 units.

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 1 variance in the outcome explained by level 2 covariates.

r2t3

proportion of treatment effect variance between level 3 units explained by level 3 covariates.

r2t4

proportion of treatment effect variance between level 4 units explained by level 4 covariates.

Value

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 - \(\alpha\))% confidence limits.

power

statistical power (1 - \(\beta\))

Examples

Run this code
# NOT RUN {
# cost constrained - optimize n3 and n4
cosa.bcrd4r2(constrain = "cost", cost = 100000,
             cn1 = c(5, 3), cn2 = 10, cn3 = 30, cn4 = 50,
             es = .20, rho2 = .20, rho3 = .10, rho4 = .05,
             omega3 = .10, omega4 = .20,
             g4 = 1,r21 = .20, r22 = .20, r2t3 = .20, r2t4 = .20,
             p = .50, n1 = 25, n2 = 3, n3 = NULL, n4 = NULL)

# minimum detectable effect size
mdes.bcrd4r2(power = .80, rho2 = .20, rho3 = .10, rho4 = .05,
             omega3 = .10, omega4 = .20,
             r21 = .20, r22 = .30, r2t3 = .40, r2t4 = .50,
             g4 = 1, p = .50, n1 = 10, n2 = 3, n3 = 50.92, n4 = 13)

# statistical power
power.bcrd4r2(es = .20, rho2 = .20, rho3 = .10, rho4 = .05,
              omega3 = .10, omega4 = .20,
              r21 = .20, r22 = .30, r2t3 = .40, r2t4 = .50,
              g4 = 1, p = .50, n1 = 10, n2 = 3, n3 = 50.92, n4 = 13)
# }

Run the code above in your browser using DataLab