Learn R Programming

cosa (version 2.0.0)

crd3: Cluster-level Regression Discontinuity (Three-level Design, Discontinuity at Level 3, w/ or w/o Strata or Fixed Blocks)

Description

Use mdes.crd3() to calculate minimum detectable effect size, power.crd3() to calculate statistical power, and cosa.crd3() for constrained optimal sample allocation. If higher level strata or fixed blocks exist, use mdes.bcrd4f3() to calculate minimum detectable effect size, power.bcrd4f3() to calculate statistical power, and cosa.bcrd4f3() for constrained optimal sample allocation. Alternatively modify degrees of freedom in <output>.crd3() functions as n3 - 2*nb - g3 - order where n3 is total number of level 3 units across blocks, and nb is number of blocks. Keep in mind that r23 now includes information about blocks, but this fact will not be reflected in g3. See examples below.

Usage

mdes.crd3(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal",
          power = .80, alpha = .05, two.tailed = TRUE, df = n3 - g3 - order - 2,
          rho2, rho3, r21 = 0, r22 = 0, r23 = 0,
          g3 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2, n3)

power.crd3(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", es = .25, alpha = .05, two.tailed = TRUE, df = n3 - g3 - order - 2, rho2, rho3, r21 = 0, r22 = 0, r23 = 0, g3 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2, n3)

cosa.crd3r3(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", cn1 = 0, cn2 = 0, cn3 = 0, cost = NULL, n1 = NULL, n2 = NULL, n3 = NULL, p = NULL, n0 = c(10, 3, 100 + g3 + 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, g3 = 0, r21 = 0, r22 = 0, r23 = 0)

mdes.bcrd4f3(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", power = .80, alpha = .05, two.tailed = TRUE, df = n4 * (n3 - 2) - g3 - order, rho2, rho3, r21 = 0, r22 = 0, r23 = 0, g3 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2, n3, n4)

power.bcrd4f3(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", es = .25, alpha = .05, two.tailed = TRUE, df = n4 * (n3 - 2) - g3 - order, rho2, rho3, r21 = 0, r22 = 0, r23 = 0, g3 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2, n3, n4)

cosa.bcrd4f3(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 + g3, 5), 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, g3 = 0, r21 = 0, r22 = 0, r23 = 0)

Arguments

score

list; an object with class 'score' returned from inspect.score() function.

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 rhots = 0 or order = 0 to obtain results equivalent to random assignment designs.

k1

numeric; left truncation point for truncated normal dist., or lower bound for uniform dist., ignored when rhots = 0 or order = 0.

k2

numeric; right truncation point for truncated normal dist., or upper bound for uniform dist., ignored when rhots = 0 or order = 0.

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.

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.

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

g3

number of covariates at level 3.

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.

rate.tp

treatment group participation rate.

rate.cc

control group crossover rate.

p

proportion of level 3 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

number of level 3 units(per stratum or block, if exists).

n4

number of stratum or fixed blocks.

cn1

marginal cost per level 1 unit in treatment and control conditions, e.g. c(10, 5).

cn2

marginal cost per level 2 unit in treatment and control conditions, e.g. c(50, 30).

cn3

marginal cost per level 3 unit in treatment and control conditions, e.g. c(80, 50).

cn4

marginal cost per stratum or fixed block.

cost

total cost or budget.

p0

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

n0

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

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

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 {
score.obj <- inspect.score(rnorm(10000), cutoff = 0)
power.crd3(score.obj, order = 2,
           es = .25, rho2 = .20, rho3 = .10,
           g3 = 0, r23 = 0, n1 = 20, n2 = 3, n3 = 100)

# with 5 blocks df = n3 - 2*(n blocks) - order - g3
# n3: number of level 3 units across five blocks
power.crd3(score.obj, order = 2, df = 100 - 2*5 - 2 - 0,
           es = .25, rho2 = .20, rho3 = .10,
           g3 = 0, r23 = .30, n1 = 20, n2 = 3, n3 = 100)

# compare
# n3: number of level 3 units per block, n4: number of blocks
power.bcrd4f3(score.obj, order = 2,
              es = .25, rho2 = .20, rho3 = .10,
              g3 = 0, r23 = .30,
              n1 = 20, n2 = 3, n3 = 20, n4 = 5)

# optimal combination of sample sizes for level 1 and level 3
# that produce power = .80 (given range restriction for level 1 sample size)
cosa.bcrd4f3(score.obj, order = 2,
             constrain = "power", power = .80,
             es = .25, rho2 = .20, rho3 = .10, g3 = 0, r23 = .30,
             n1 = c(20, 60), n2 = 2, n3 = NULL, n4 = 5)
# }

Run the code above in your browser using DataLab