Longnitudal Design with repeated intervention

How could one create a longnitudal Design with DeclareDesign with repeated interventions and measurement?

For example, if one would have two groups (treatment & placebo) and every unit would receive either the treatment or the placebo once a month over a duration of X-months. And one would spread the intervention in 4 blocks (by week of the month), so that the first block receives the treatment or placebo in the first week of the month, second block in the second week and so on. Imagine one could measure every unit, every week, starting one week before the intervention until X-months after the last intervention took place.

You might be able to do this with blocking features in randomizr, but I found it easier to write a custom assignment function.

I read your story problem as doing complete RA over weeks 1-4, and then when the week # matched the assignment, do treatment (Z=1).

#> Loading required package: DeclareDesign
#> Loading required package: randomizr
#> Loading required package: fabricatr
#> Loading required package: estimatr

p <- declare_population(
  subjects=add_level(N=10, s_i=1:N),
  weeks=add_level(N=4, w_i=1:4)

a <- declare_assignment(handler=function(data){
  g <- complete_ra(max(data$s_i), conditions=1:4)

  within(data, Z <- +(g[s_i] == w_i))

design <- p+a

xtabs(~w_i+s_i, draw_data(design), subset = Z == 1)
#>    s_i
#> w_i  1  2  3  4  5  6  7  8  9 10
#>   1  0 12  0  0  0  0  0  0  0 12
#>   2 12  0  0 12  0  0 12  0  0  0
#>   3  0  0  0  0 12  0  0 12 12  0
#>   4  0  0 12  0  0 12  0  0  0  0

Created on 2019-08-29 by the reprex package (v0.3.0)

The rest of the design (potential outcomes, estimands and estimation, revealing outcomes, …) should be pretty standard. There’s a couple redundant columns in my design above, but those coudl be cleaned up easily.

You can add extra conditions in the assignment function too (eg no more treatments after month 6, for example). You could also filter down the output to only observe weeks one week before first treatment through X months after final treatment.

1 Like

thanks a lot. In this design, every unit would receive a treatment at some point. One would also need to declare another assignment to differentiate between placebo and treatment, or?

To me the rest does not look too easy. Let’s assume the outcome is some normal distributed variable over all units, that increase slowly over time with a normal distribution each week for all units. Additionally the outcome in the treatment group should increase additionally in the week of treatment and in the week after the treatment, thereafter decreasing again for two weeks (but slightly less than it did increase) until the treatment is repeated (picture it like an upward wave).