DeclareDesign Community

N by m experiments where (n, m) > 2


#1

First off, thanks for a terrific resource.

I’m wondering if there’s a built-in command for declaring an n by m design where the numbers of treatments in both conditions is greater than 2.

I’m trying to perform a power analysis for a 3 by 3 survey experiment. Perhaps I’m just missing something – but it looks like a factorial design with more than 2 conditions in each randomization would need to be programmed by hand (using a more elaborate version of your template for the 2^k factorial design – modified for a 3x3 or something else). Please advise, and thanks much!

Eric


#2

Hi Eric!

I think you can think of this in two ways.

You could imagine this is a 9-arm trial:


> design <- 
+   declare_population(N = 100) +
+   declare_assignment(num_arms = 9)
> 
> dat <- draw_data(design)
> head(dat)
   ID  Z Z_cond_prob
1 001 T9   0.1111111
2 002 T7   0.1111111
3 003 T3   0.1111111
4 004 T7   0.1111111
5 005 T3   0.1111111
6 006 T3   0.1111111
> with(dat, table(Z))
Z
T1 T2 T3 T4 T5 T6 T7 T8 T9 
11 11 11 11 11 12 11 11 11 

or as first assigning the first factor and then assigning the second factor, blocking on the first

> design <- 
+ declare_population(N = 100) +
+   declare_assignment(num_arms = 3, assignment_variable = "F1") +
+   declare_assignment(num_arms = 3,
+                      blocks = F1,
+                      assignment_variable = "F2")
> 
> dat <- draw_data(design)
> head(dat)
   ID F1 F1_cond_prob F2 F2_cond_prob
1 001 T1    0.3333333 T2    0.3333333
2 002 T1    0.3333333 T1    0.3333333
3 003 T3    0.3333333 T3    0.3333333
4 004 T1    0.3333333 T1    0.3333333
5 005 T2    0.3333333 T1    0.3333333
6 006 T2    0.3333333 T2    0.3333333
> with(dat, table(F1, F2))
    F2
F1   T1 T2 T3
  T1 11 11 12
  T2 11 11 11
  T3 11 11 11

I think the second way might make it easier to write out your expecations about potnetial outcomes and also in the analysis step!


#3

Thanks, Alex! That’s exactly what I needed. I’d thought to do the 9-arm set-up, but figured there was a better means of accomplishing the same thing.

This is the best-sourced R package I’ve ever worked with! - terrific stuff.

Eric