DesignLibrary (version 0.1.0)

simple_factorial_designer: Create a simple factorial design

Description

Builds a two-by-two factorial design in which assignments to each factor are independent of each other.

Usage

simple_factorial_designer(N = 100, prob_A = 0.5, prob_B = 0.5,
  w_A = 0.5, w_B = 0.5, outcome_means = rep(0, 4),
  mean_A0B0 = outcome_means[1], mean_A0B1 = outcome_means[2],
  mean_A1B0 = outcome_means[3], mean_A1B1 = outcome_means[4],
  outcome_sds = rep(1, 4))

Arguments

N

An integer. Size of sample.

prob_A

A number in [0,1]. Probability of assignment to treatment A.

prob_B

A number in [0,1]. Probability of assignment to treatment B.

w_A

A number. Weight placed on A=1 condition in definition of "average effect of B" estimand.

w_B

A number. Weight placed on B=1 condition in definition of "average effect of A" estimand.

outcome_means

A vector of length 4. Average outcome in each A,B condition, in order AB = 00, 01, 10, 11. Values overridden by mean_A0B0, mean_A0B1, mean_A1B0, if provided mean_A1B1.

mean_A0B0

A number. Mean outcome in A=0, B=0 condition.

mean_A0B1

A number. Mean outcome in A=0, B=1 condition.

mean_A1B0

A number. Mean outcome in A=1, B=0 condition.

mean_A1B1

A number. Mean outcome in A=1, B=1 condition.

outcome_sds

A non-negative 4-vector. Standard deviation in each condition, in order AB = 00, 01, 10, 11.

Value

A two-by-two factorial design.

Details

Three types of estimand are declared: weighted averages of the average treatment effects of each treatment over the two conditions of the other treatment and the difference in treatment effects of each over conditions of the other.

Treatment A is assigned first and then Treatment B within blocks defined by treatment A. Thus eg if there are 6 units 3 are guaranteed to receive treatment A but the number receiving treatment B is stochastic.

Units are assigned to treatment using complete random assignment. Potential outcomes follow a normal distribution.

See multi_arm_designer for a factorial design with non independent assignments.

Examples

Run this code
# NOT RUN {
design <- simple_factorial_designer(outcome_means = c(0,0,0,1))

# A design biased for the specified estimands:
design <- simple_factorial_designer(outcome_means = c(0,0,0,1), prob_A = .8, prob_B = .2)
# }
# NOT RUN {
diagnose_design(design)
# }
# NOT RUN {
# A design with estimands that "match" the assignment:
design <- simple_factorial_designer(outcome_means = c(0,0,0,1), 
                                    prob_A = .8, prob_B = .2, 
                                    w_A = .8, w_B = .2)
# }
# NOT RUN {
diagnose_design(design)
# }
# NOT RUN {
# Compare power with and without interactions, given same average effects in each arm
designs <- redesign(simple_factorial_designer(), 
                    outcome_means = list(c(0,0,0,1), c(0,.5,.5,1)))
# }
# NOT RUN {
diagnose_design(designs)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab