Learn R Programming

cosa (version 2.0.0)

ird: Simple Individual-level Regression Discontinuity (w/ or w/o Strata or Fixed Blocks)

Description

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

Usage

mdes.ird(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal",
         power = .80, alpha = .05, two.tailed = TRUE, df = n1 - g1 - order - 2,
         r21 = 0, g1 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1)

power.ird(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", es = .25, alpha = .05, two.tailed = TRUE, df = n1 - g1 - order - 2, r21 = 0, g1 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1)

mdes.bird2f1(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", power = .80, alpha = .05, two.tailed = TRUE, df = n2 * (n1 - 2) - g1 - order, r21 = 0, g1 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2 = 1)

power.bird2f1(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", es = .25, alpha = .05, two.tailed = TRUE, df = n2 * (n1 - 2) - g1 - order, r21 = 0, g1 = 0, rate.tp = 1, rate.cc = 0, p = .50, n1, n2 = 1)

cosa.bird2f1(score = NULL, order = 2, rhots = NULL, k1 = -6, k2 = 6, dists = "normal", cn1 = 0, cn2 = 0, cost = NULL, n1 = NULL, n2 = NULL, p = NULL, n0 = c(400 + g1, 5), p0 = .499, constrain = "power", round = TRUE, max.power = FALSE, local.solver = c("LBFGS", "SLSQP"), power = .80, es = .25, alpha = .05, two.tailed = TRUE, g1 = 0, r21 = 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

numeric > 0; 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.

g1

number of covariates.

r21

proportion of variance in the outcome explained by covariates.

p

proportion of units in treatment condition.

rate.tp

treatment group participation rate.

rate.cc

control group crossover rate.

n1

sample size (per stratum or block, if exists).

n2

number of stratum or fixed blocks.

cn1

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

cn2

marginal cost per stratum or fixed block.

cost

total cost or budget.

constrain

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

n0

starting value for n1 or n1, n2. Starting value is replaced with average when sample size is 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.

round

logical; TRUE for rounded COSA solution.

max.power

logical; TRUE for maximizing power instead of minimizing 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

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.ird(score.obj, order = 2,
          es = 0.25, g1 = 0, r21 = 0, n = 400)

# with 5 blocks df = n1 - 2*(n blocks) - order - g1
# n1: number of subjects across five blocks
power.ird(score.obj, order = 2, df = 400 - 2*5 - 2 - 0,
          es = 0.25, g1 = 0, r21 = .30, n = 400)

# compare
# n1: number of subjects per block, n2: number of blocks
power.bird2f1(score.obj, order = 2,
              es = 0.25, g1 = 0, r21 = .30,
              n1 = 80, n2 = 5)

# optimal combination of sample sizes for subjects and blocks
# that produce power = .80 (given range restrictions)
cosa.bird2f1(score.obj, order = 2,
             constrain = "power", power = .80,
             es = 0.25, g1 = 0, r21 = .30,
             n1 = c(100, 200), n2 = c(5, 10))
# }

Run the code above in your browser using DataLab