# Unconstrained optimal design #---------
myod1 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5,
c1 = 1, c2 = 10, c1t = 10,
varlim = c(0, 0.005))
myod1$out # n = 19.8, p = 0.37
# ------- Power analyses by default considering costs and budget -------
# Required budget and sample size
mym.1 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8)
mym.1$out # m = 2019, J = 20.9
# mym.1$par # parameters and their values used for the function
# Or, equivalently, specify every argument in the function
mym.1 <- power.2m(d = 0.2, power = 0.8, q = 1,
icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5,
c1 = 1, c2 = 10, c1t = 10,
n = 20, p = 0.37)
# Required budget and sample size with constrained p
mym.2 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8,
constraint = list(p = 0.5))
mym.2$out # m = 2373, J = 19.8
# Required budget and sample size with constrained p and n
mym.3 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8,
constraint = list(p = 0.5, n = 5))
mym.3$out # m = 2502, J = 66.7
# Power calculation
mypower <- power.2m(expr = myod1, q = 1, d = 0.2, m = 2019)
mypower$out # power = 0.80
# Power calculation under constrained p (p = 0.5)
mypower.1 <- power.2m(expr = myod1, q = 1, d = 0.2, m = 2019,
constraint = list(p = 0.5))
mypower.1$out # power = 0.72
# MDES calculation
mymdes <- power.2m(expr = myod1, q = 1, power = 0.80, m = 2019)
mymdes$out # d = 0.20
# ------- Conventional power analyses with cost.model = FALSE-------
# Required sample size
myJ <- power.2m(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8)
myJ$out # J = 6.3
# myL$par # parameters and their values used for the function
# Or, equivalently, specify every argument in the function
myJ <- power.2m(cost.model = FALSE, d = 0.2, power = 0.8, q = 1,
icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5,
c1 = 1, c2 = 10, c1t = 10,
n = 20, p = 0.37)
# Power calculation
mypower1 <- power.2m(cost.model = FALSE, expr = myod1, J = 6.3, d = 0.2, q = 1)
mypower1$out # power = 0.80
# MDES calculation
mymdes1 <- power.2m(cost.model = FALSE, expr = myod1, J = 6.3, power = 0.8, q = 1)
mymdes1$out # d = 0.20
Run the code above in your browser using DataLab