Learn R Programming

PowerUpR (version 1.0.1)

cra2r2: Two-level Cluster-randomized Trials to Detect Main, Moderation and Mediation Effects

Description

Use mdes.<design>() to calculate minimum detectable effect size for main effect, mdesd.<design>() to calculate minimum detectable effect size difference for moderation effect, power.<design>() to calculate statistical power, and mrss.<design>() to calculate minimum required sample size. Use <output>.cra2r2() for main effect, <output>.mod221() for moderator effect at level 1, <output>.mod222() for moderator effect at level 2, power.med211() for 2-1-1 mediation effect, and power.med221() for 2-2-1 mediation effect.

Usage

mdes.cra2r2(power=.80, alpha=.05, two.tailed=TRUE,
            rho2, p=.50, g2=0, r21=0, r22=0,
            n, J)

mdesd.mod221(power=.80, alpha=.05, two.tailed=TRUE, rho2, omegam2, g1=0, r21=0, r2m2=0, p=.50, q=NULL, n, J)

mdesd.mod222(power=.80, alpha=.05, two.tailed=TRUE, rho2, g2=0, r21=0, r22=0, p=.50, q=NULL, n, J)

power.cra2r2(es=.25, alpha=.05, two.tailed=TRUE, rho2, g2=0, p=.50, r21=0, r22=0, n, J)

power.mod221(es=.25, alpha=.05, two.tailed=TRUE, rho2, omegam2, g1=0, r21=0, r2m2=0, p=.50, q=NULL, n, J)

power.mod222(es=.25, alpha=.05, two.tailed=TRUE, rho2, g2=0, r21=0, r22=0, p=.50, q=NULL, n, J)

power.med211(esa, esb1, esB, escp, two.tailed = TRUE, alpha = .05, mc = FALSE, nsims = 1000, ndraws = 1000, rhom2, rho2, r21, r22, r2m1, r2m2, p, n, J)

power.med221(esa, esb, escp, two.tailed = TRUE, alpha = .05, mc = FALSE, nsims = 1000, ndraws = 1000, rho2, r22, r21, r2m2, p = .50, n, J)

mrss.cra2r2(es=.25, power=.80, alpha=.05, two.tailed=TRUE, n, J0=10, tol=.10, rho2, g2=0, p=.50, r21=0, r22=0)

mrss.mod221(es=.25, power=.80, alpha=.05, two.tailed=TRUE, n, J0=10, tol=.10, rho2, omegam2, g1=0, r21=0, r2m2=0, p=.50, q=NULL)

mrss.mod222(es=.25, power=.80, alpha=.05, two.tailed=TRUE, n, J0=10, tol=.10, rho2, g2=0, r21=0, r22=0, p=.50, q=NULL)

mrss.mod222(es=.25, power=.80, alpha=.05, two.tailed=TRUE, n, J0=10, tol=.10, rho2, g2=0, r21=0, r22=0, p=.50, q=NULL)

Arguments

power

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

es, esa, esb, esb1, esB, escp

effect size for main/moderator effects, or for path coefficients a (treatment - mediator), b (level 2 mediator - outcome), b1 (level 1 mediator - outcome), B (overall mediator - outcome) or cp (direct treatment - outcome) in the mediation model.

alpha

probability of type I error.

two.tailed

logical; FALSE for one-tailed hypothesis testing.

rho2

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

rhom2

proportion of variance in the mediator between level 2 units.

omegam2

ratio of the unconditional variance in the moderator effect that is between level 2 units to the residual variance between level 2 units in the null model.

p

proportion of level 2 units randomly assigned to treatment.

q

proportion of level 1 or level 2 units in the moderator subgroup.

g1

number of covariates at level 1.

g2

number of covariates at level 2.

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.

r2m1

proportion of mediator variance at level 1 explained by level 1 covariates.

r2m2

proportion of variance in the moderator (or mediator) effect that is explained by level 2 covariates. For the mediation model, proportion of mediator variance at level 2 exaplained by level 2 covariates.

n

harmonic mean of level 1 units across level 2 units (or simple average).

J

level 2 sample size.

J0

starting value for J.

tol

tolerance to end iterative process for finding J.

mc

logical; TRUE for monte carlo simulation based power.

nsims

number of replications, if mc = TRUE.

ndraws

number of draws from the distribution of the path coefficients for each replication, if mc = TRUE.

Value

fun

function name.

parms

list of parameters used in power calculation.

df

degrees of freedom.

ncp

noncentrality parameter.

power

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

mdes

minimum detectable effect size.

J

number of level 2 units.

See Also

For a more flexible sample size determination see cosa.crd2r2.

Examples

Run this code
# NOT RUN {
# cross-checks for the main effect
mdes.cra2r2(rho2=.17, n=15, J=20)
power.cra2r2(es=.629, rho2=.17, n=15, J=20)
mrss.cra2r2(es=.629, rho2=.17, n=15)

# cross-checks for the randomly varying cont. L1 moderator effect
mdes.mod221(rho2=.17, omegam2=.10, n=15, J=20)
power.mod221(es=.3563, rho2=.17, omegam2 =.10, n=15, J=20)
mrss.mod221(es=.3563, rho2=.17, omegam2 =.10, n=15)

# cross-checks for the non-randomly varying cont. L1 moderator effect
mdes.mod221(rho2=.17, omegam2=0, n=15, J=20)
power.mod221(es=0.2957, rho2=.17, omegam2 =0, n=15, J=20)
mrss.mod221(es=0.2957, rho2=.17, omegam2 =0, n=15)

# cross-checks for the randomly varying bin. L1 moderator effect
mdesd.mod221(rho2=.17, omegam2=.10, q=.50, n=15, J=20)
power.mod221(es=.647, rho2=.17, omegam2 =.10, q=.50, n=15, J=20)
mrss.mod221(es=.647, rho2=.17, omegam2 =.10, q=.50, n=15)

# cross-checks for the non-randomly varying bin. L1 moderator effect
mdesd.mod221(rho2=.17, omegam2=0, q=.50, n=15, J=20)
power.mod221(es=0.5915, rho2=.17, omegam2 =0, q=.50, n=15, J=20)
mrss.mod221(es=0.5915, rho2=.17, omegam2 =0, q=.50, n=15)

# cross-checks for the cont. L2 moderator effect
mdesd.mod222(rho2=.17, n=15, J=100)
power.mod222(es=0.2742, rho2=.17, n=15, J=100)
mrss.mod222(es=0.2742, rho2=.17, n=15)

# cross-checks for the bin. L2 moderator effect
mdesd.mod222(rho2=.17, q=.50, n=15, J=100)
power.mod222(es=0.5485, rho2=.17, q=.50, n=15, J=100)
mrss.mod222(es=0.5485, rho2=.17, q=.50, n=15)

# 2-2-1 mediation
power.med221(esa=0.6596, esb=0.1891, escp=.1,
             rho2=.15, r22=.52, r21=.40, r2m2=.50,
             n=100, J=40, p=.5)

# 2-1-1 mediation
power.med211(esa=0.4135, esb1=0.0670, esB=0.3595, escp=.1,
            rhom2=.3, rho2=.3, r22=.6, r21=.6, r2m2=.6, r2m1=.6,
            n=30, J=80, p=.1)
# }

Run the code above in your browser using DataLab