# getAveraging: Convert design into averaging matrices. In shuffle: The Shuffle Estimator for Explainable Variance

## Description

getAveraging(des) converts a design (either a vector or a matrix) into averaging matrix notation (from the paper). For a response vector Y, (B Y)[t] is the mean of all responses corresponding to the treatment at time t, and (B-G)Y [t] is the averaged-removed treatment mean.

## Usage

 `1` ```getAveraging(des) ```

## Arguments

 `des` Either a vector or a matrix representation of design (see designVec2Mat and designMat2Vec).

## Value

A list with components

 `m` The number of treatments `ns` An m-length vector with the number of repeats for each treatment. For balanced designs with n repeats, ns=rep(n,m) `B` The averaging matrix according to the design `G` 1/T for T the number of measurements

Yuval Benjamini

## References

Benjamini and Yu (2013).

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10``` ```data(design_vec) design_avg = getAveraging(design_vec) rand_resp = rnorm(length(design_vec)) global_mean = mean(rand_resp[design_vec != 0 ]) first_treatment_mean= mean(rand_resp[design_vec == design_vec[1]]) cat((design_avg\$B %*% rand_resp)[1], first_treatment_mean ) cat(((design_avg\$B-design_avg\$G) %*% rand_resp)[1], first_treatment_mean- global_mean) ```

### Example output

```-0.1578266 -0.1578266-0.1370588 -0.1370588
```

shuffle documentation built on May 2, 2019, 1:45 p.m.