quickblock (version 0.2.0)

# blocking_estimator: Estimator for treatment effects in blocked experiments

## Description

blocking_estimator estimates treatment effects in blocked experiments. The function expects the user to provide the outcomes, a blocking object and treatment assignments. It returns point estimates of sample average treatment effects and variance estimates.

## Usage

blocking_estimator(outcomes, blocking, treatments)

## Arguments

outcomes

numeric vector with observed outcomes.

blocking

qb_blocking or scclust object with the block assignments.

treatments

factor specifying the units' treatment assignments.

## Value

A list with two numeric matrices with estimated treatment effects and their estimated variances is returned. The first matrix (effects) contains estimated treatment effects. Rows in this matrix indicate minuends in the treatment effect contrast and columns indicate subtrahends. For example, in the matrix:

 a b c a 0.0 4.5 5.5 b -4.5 0.0 1.0 c -5.5 -1.0 0.0

the estimated treatment effect between conditions $$a$$ and $$b$$ is $$4.5$$, and the estimated treatment effect between conditions $$c$$ and $$b$$ is $$-1.0$$.

The second matrix (effect_variances) contains estimates of variances of the corresponding effect estimators.

## Details

To produce point estimates, blocking_estimator requires that each block contains at least one unit assigned to each treatment condition. For variance estimation, it requires that each block contains at least two units assigned to each condition. When treatments have been assigned with the assign_treatment function (or an equivalent procedure), the variance estimators are conservative in expectation (see the referenced note below for details). If treatment is assigned with another method, the estimator might not be valid.

The function estimates treatment effects by aggregating block-level effect estimates. It estimates effects within each block by taking the difference in mean outcomes in the block. The sample-level estimate is then derived as the weighted average of the block-level effects using the size of the blocks as weights. In detail, let $$n_b$$ be the number of units assigned to block $$b$$, and $$n$$ be the total number of units in the sample. Let $$Y(t, b)$$ be the average outcome for units assigned to treatment $$t$$ in block $$b$$. The effect of treatment $$t$$ versus treatment $$s$$ is then estimated as:

$$\sum\frac{n_b}{n}[Y(t, b) - Y(s, b)],$$

where the sum is taken over the blocks in the experiment. See the referenced note for more details.

## References

Higgins, Michael J., Fredrik S<U+00E4>vje and Jasjeet S. Sekhon (2015), ‘Blocking estimators and inference under the Neyman-Rubin model’, arXiv 1510.01103. https://arxiv.org/abs/1510.01103

## Examples

# NOT RUN {
# Example blocking
my_blocking <- qb_blocking(c("A", "A", "B", "C", "B",
"C", "B", "C", "B", "A",
"C", "C", "A", "B", "B",
"B", "B", "A", "A", "C"))

# Two treatment conditions
my_treatments <- assign_treatment(my_blocking)
my_outcomes <- rnorm(20)
blocking_estimator(my_outcomes, my_blocking, my_treatments)

# Three treatment conditions
my_treatments <- assign_treatment(my_blocking, c("T1", "T2", "C"))
my_outcomes <- rnorm(20)
blocking_estimator(my_outcomes, my_blocking, my_treatments)

# Four treatment conditions
# (This will throw an error because variances cannot be estimated)
my_treatments <- assign_treatment(my_blocking, c("T1", "T2", "T3", "C"))
my_outcomes <- rnorm(20)
# }
# NOT RUN {
blocking_estimator(my_outcomes, my_blocking, my_treatments)
# }
# NOT RUN {
# }