Simulate by Design

library(faux)

The sim_design() function creates a dataset with a specific between- and within-subjects design.

Quick example

For example, the following creates a 4w*2b design with 100 observations in each cell. The between-subject factor is pet with two levels (“cat” and “dog”). The within-subject factor is time with four levels (“morning”, “noon”, “evening” and “night”).

The data is sampled from a population where the mean for the cat_morning cell is 10, the mean for the cat_noon cell is 12, the mean for the cat_evening cell is 14, and the mean for the cat_night cell is 16. The mean for the dog_morning cell is 10, the mean for the dog_noon cell is 15, the mean for the dog_evening cell is 20, and the mean for the dog_night cell is 25. All cells have a SD of 5 and all within-subject cells are correlated r = 0.5.

between <- list(pet = c(cat = "Cat Owners", 
                        dog = "Dog Owners"))
within <- list(time = c("morning", "noon", "evening", "night"))
mu <- data.frame(
  cat    = c(10, 12, 14, 16),
  dog    = c(10, 15, 20, 25),
  row.names = within$time
)
# add factor labels for plotting
vardesc <- c(pet = "Type of Pet",
             time = "Time of Day")

df <- sim_design(within, between, 
                 n = 100, mu = mu, sd = 5, r = .5,
                 empirical = TRUE, vardesc = vardesc, plot = TRUE)

Specification of design parameters

Factor and level names

Anonymous

If you don’t feel like naming your factors and levels, you can just put in a vector of levels. So you can make a quick 2w*3w*2b with the following code.

df <- sim_design(within = c(2,3), between = c(2), 
                 n = 10, mu = 1:12, sd = 1, r = 0.5)

List of vectors

You can specify between-subject and within-subject factors as a list of vectors where the item names are the factor labels and the vectors are the level labels.

between <- list(
  pet = c("cat", "dog")
)
within <- list(
  time = c("day", "night")
)

df <- sim_design(within, between, mu = 1:4)

Levels with underscores

In wide format, faux uses an underscore to separate level names. Therefore, any underscores in factor level names will generate an error.

# with default sep = _
within <- list(
  A = c("A_1", "A_2"),
  B = c("B_1", "B_2")
)

sim_design(within, n = 5, plot = FALSE)
#> Error in check_design(within = within, between = between, n = n, mu = mu, : These level names have the separator '_' in them: A_1, A_2, B_1, B_2
#> Please change the names (see fix_name_labels) or choose another separator character using the sep argument or faux_options(sep = '~')
#> safe separators for your factor labels are: _

You can change this default with faux_options().

faux_options(sep = ".")

sim_design(within, n = 5, plot = FALSE)
#>   id A_1.B_1 A_1.B_2 A_2.B_1 A_2.B_2
#> 1 S1  0.2676  -1.043 -0.7612  -1.421
#> 2 S2 -1.2634  -0.693 -0.2714  -0.307
#> 3 S3 -1.0505   0.967  1.6351   0.693
#> 4 S4  0.6510   0.278  0.7763  -0.920
#> 5 S5  0.0102  -0.125 -0.0494   0.431
# put the separator back to _ for the rest of this vignette
faux_options(sep = "_")

List of named vectors/lists

You can also specify factors as a list of named vectors or lists where the item names are the factor labels, the vector names are the level labels that are used in the data table, and the vector items are the long labels for a codebook or plot.

between <- list(
  pet = c(cat = "Is a cat person", dog = "Is a dog person")
)
within <- list(
  time = c(day = "Tested during the day", night = "Tested at night")
)
df <- sim_design(within, between, mu = 1:4)

#### Factor labels

Add factor labels with the vardesc argument. You can also customise the ID and DV column names (they default to c(id = "id") and c(y = "value")).

vardesc <- c(pet = "Type of Pet",
             time = "Time of Day")

df <- sim_design(within, between, mu = 1:4, 
                 id = c(pet_id = "Pet ID"),
                 dv = c(score = "Score on the Test"),
                 vardesc = vardesc)

If you have any within-subjects factors and your table is in wide format, you will only see the DV name in plots. But it will be used if you convert the table from wide to long.

wide2long(df) %>% head()
#>   pet_id pet time  score
#> 1   S001 cat  day  2.130
#> 2   S002 cat  day  2.108
#> 3   S003 cat  day  0.601
#> 4   S004 cat  day -0.619
#> 5   S005 cat  day  0.129
#> 6   S006 cat  day  1.149

Specifying N

You can specify the Ns for each between-subject cell as a single number, named list, or data frame.

Single number

You usually want to specify n as a single number. This is N per cell, not total sample size.

n <- 20 # n per cell, not total
design <- check_design(2, c(2,2), n = n, plot = FALSE)
str(design$n)
#> List of 4
#>  $ B1a_B2a: num 20
#>  $ B1a_B2b: num 20
#>  $ B1b_B2a: num 20
#>  $ B1b_B2b: num 20

Named list

You can also specify n as a named list of Ns per between-subject cell.

n <- list(
  B1a_B2a = 10, 
  B1a_B2b = 20, 
  B1b_B2a = 30, 
  B1b_B2b = 40
)
design <- check_design(2, c(2,2), n = n, plot = FALSE)
str(design$n)
#> List of 4
#>  $ B1a_B2a: num 10
#>  $ B1a_B2b: num 20
#>  $ B1b_B2a: num 30
#>  $ B1b_B2b: num 40

Dataframe

Or as a data frame. You just need to get the row or column names right, but they don’t have to be in the right order.

n <- data.frame(
  B1b_B2b = 40,
  B1a_B2a = 10, 
  B1a_B2b = 20, 
  B1b_B2a = 30
)
design <- check_design(2, c(2,2), n = n, plot = FALSE)
str(design$n)
#> List of 4
#>  $ B1a_B2a: num 10
#>  $ B1a_B2b: num 20
#>  $ B1b_B2a: num 30
#>  $ B1b_B2b: num 40

You can specify the cells as row names or column names and check_design() will fix them. Since n has to be the same for each within-subject factor, you can specify n as a single column with any name.

n <- data.frame(n = c(10, 20, 30, 40),
                row.names = c("B1a_B2a", "B1a_B2b", "B1b_B2a", "B1b_B2b"))
design <- check_design(2, c(2,2), n = n, plot = FALSE)
str(design$n)
#> List of 4
#>  $ B1a_B2a: num 10
#>  $ B1a_B2b: num 20
#>  $ B1b_B2a: num 30
#>  $ B1b_B2b: num 40

Mu and SD

The specifications for mu and sd need both within-subject and between-subject cells. You can specify these as a single numbers, a vector, a named list of named vectors or a data frame.

Unnamed vector

An unnamed vector is a quick way to specify means and SDs, but the order relative to your between- and within-subject cells can be confusing.

between <- list(pet       = c("cat", "dog"), 
                condition = c("A",   "B"))
within  <- list(time      = c("day", "night"))
mu <- c(10, 20, 30, 40, 50, 60, 70, 80)
design <- check_design(within, between, mu = mu, plot = FALSE)
str(design$mu)
#> List of 4
#>  $ cat_A:List of 2
#>   ..$ day  : num 10
#>   ..$ night: num 20
#>  $ cat_B:List of 2
#>   ..$ day  : num 30
#>   ..$ night: num 40
#>  $ dog_A:List of 2
#>   ..$ day  : num 50
#>   ..$ night: num 60
#>  $ dog_B:List of 2
#>   ..$ day  : num 70
#>   ..$ night: num 80

Named list of named vectors

A named list of named vectors prevents confusion due to order. The levels of the between-subject factors are the list names and the levels of the within-subject factors are the vector names, but their order doesn’t matter.

mu <- list(
  cat_B = c(night = 40, day = 30),
  cat_A = c(day = 10, night = 20),
  dog_A = c(day = 50, night = 60),
  dog_B = c(day = 70, night = 80)
)
design <- check_design(within, between, mu = mu, sd = 1, plot = FALSE)
str(design$mu)
#> List of 4
#>  $ cat_A:List of 2
#>   ..$ day  : num 10
#>   ..$ night: num 20
#>  $ cat_B:List of 2
#>   ..$ day  : num 30
#>   ..$ night: num 40
#>  $ dog_A:List of 2
#>   ..$ day  : num 50
#>   ..$ night: num 60
#>  $ dog_B:List of 2
#>   ..$ day  : num 70
#>   ..$ night: num 80

Alternatively, you can specify them as data frames.

mu <- data.frame(
  cat_A = c(10, 20),
  cat_B = c(30, 40),
  dog_A = c(50, 60),
  dog_B = c(70, 80),
  row.names = c("day", "night")
)
design <- check_design(within, between, mu = mu, plot = FALSE)
str(design$mu)
#> List of 4
#>  $ cat_A:List of 2
#>   ..$ day  : num 10
#>   ..$ night: num 20
#>  $ cat_B:List of 2
#>   ..$ day  : num 30
#>   ..$ night: num 40
#>  $ dog_A:List of 2
#>   ..$ day  : num 50
#>   ..$ night: num 60
#>  $ dog_B:List of 2
#>   ..$ day  : num 70
#>   ..$ night: num 80

If you transpose the dataframe, this works out fine unless your within- and between-subject cells have identical names.

mu <- data.frame(
  day = c(10, 30, 50, 70),
  night = c(20, 40, 60, 80),
  row.names = c("cat_A", "cat_B", "dog_A", "dog_B")
)
design <- check_design(within, between, mu = mu, plot = FALSE)
str(design$mu)
#> List of 4
#>  $ cat_A:List of 2
#>   ..$ day  : num 10
#>   ..$ night: num 20
#>  $ cat_B:List of 2
#>   ..$ day  : num 30
#>   ..$ night: num 40
#>  $ dog_A:List of 2
#>   ..$ day  : num 50
#>   ..$ night: num 60
#>  $ dog_B:List of 2
#>   ..$ day  : num 70
#>   ..$ night: num 80

Correlations

If you have any within-subject factors, you need to set the correlation for each between-cell. Here, we only have two levels of one within-subject factor, so can only set one correlation per between-cell.

r <- list(
  cat_A = .5,
  cat_B = .5,
  dog_A = .6,
  dog_B = .4
)
design <- check_design(within, between, r = r, plot = FALSE)
design$r
#> $cat_A
#>       day night
#> day   1.0   0.5
#> night 0.5   1.0
#> 
#> $cat_B
#>       day night
#> day   1.0   0.5
#> night 0.5   1.0
#> 
#> $dog_A
#>       day night
#> day   1.0   0.6
#> night 0.6   1.0
#> 
#> $dog_B
#>       day night
#> day   1.0   0.4
#> night 0.4   1.0

Upper right triangle

If you have more than 2 within-subject cells, you can specify each specific correlation in the upper right triangle of the correlation matrix as a vector.

r <- list(
  B1a = c(.10, .20, .30, 
              .40, .50, 
                   .60),
  B1b = c(.15, .25, .35, 
              .45, .55, 
                   .65)
)
design <- check_design(4, 2, r = r, plot = FALSE)
design$r
#> $B1a
#>     W1a W1b W1c W1d
#> W1a 1.0 0.1 0.2 0.3
#> W1b 0.1 1.0 0.4 0.5
#> W1c 0.2 0.4 1.0 0.6
#> W1d 0.3 0.5 0.6 1.0
#> 
#> $B1b
#>      W1a  W1b  W1c  W1d
#> W1a 1.00 0.15 0.25 0.35
#> W1b 0.15 1.00 0.45 0.55
#> W1c 0.25 0.45 1.00 0.65
#> W1d 0.35 0.55 0.65 1.00

Correlation matrix

You can also enter the correlation matrix from cor().

within <- list(cars = c("speed", "dist"))
between <- list(half = c("first", "last"))
r <- list(
  first = cor(cars[1:25,]),
  last = cor(cars[26:50,])
)

design <- check_design(within, between, r = r, plot = FALSE)
design$r
#> $first
#>       speed  dist
#> speed 1.000 0.609
#> dist  0.609 1.000
#> 
#> $last
#>       speed  dist
#> speed 1.000 0.669
#> dist  0.669 1.000

Empirical

If you set empirical = TRUE, you will get the exact means, SDs and correlations you specified. If you set empirical = FALSE or omit that argument, your data will be sampled from a population with those parameters, but your dataset will not have exactly those values (just on average).

between <- list(pet  = c("cat", "dog"))
within  <- list(time = c("day", "night"))
mu <- list(
  cat = c(day = 10, night = 20),
  dog = c(day = 30, night = 40)
)

sd <- list(
  cat = c(day = 5, night = 10),
  dog = c(day = 15, night = 20)
)

r <- list(cat = .5, dog = .6)

df <- sim_design(within, between, n = 100, 
                 mu = mu, sd = sd, r = r,
                 empirical = TRUE)

pet n var day night mean sd
cat 100 day 1.0 0.5 10 5
cat 100 night 0.5 1.0 20 10
dog 100 day 1.0 0.6 30 15
dog 100 night 0.6 1.0 40 20

More factors

Here is a 2w*3w*2b*2b example. When you have multiple within or between factors, you need to specify parameters by cell. Cell names are the level names, in the order they are listed in the within or between arguments, separated by underscores.

Foe example, if you have one within-subject factor of condition with levels con and inc, and another within-subject factor of version with levels easy, med, and hard, your cell labels will be: con_easy, inc_easy, con_med, inc_med, con_hard, and inc_hard.

If you have any characters in your level names except letters and numbers, they will be replaced by a full stop (e.g., my super-good level_name will become my.super.good.level.name).

within <- list(
  condition = c(con = "Mean of congruent trials", 
                inc = "Mean of incongruent trials"),
  version = c(easy = "Easy", 
              med  = "Medium", 
              hard = "Difficult")
)

between <- list(
  experience = c(novice = "Novice", expert = "Expert"),
  time = c(day = "Before 5pm", night = "After 5pm")
)

mu <- data.frame(
  row.names = c("con_easy", "con_med", "con_hard",
                "inc_easy", "inc_med",  "inc_hard"),
  novice_day = 10:15,
  novice_night = 11:16,
  expert_day = 9:14,
  expert_night = 10:15
)

You can set the correlation for each between-cell to a single number.

r <- list(
  novice_day = 0.3,
  novice_night = 0.2,
  expert_day = 0.5,
  expert_night = 0.4
)

Or you can set the full correlation matrix with a vector or matrix. Since we have 6 within-cells, this is a 6x6 matrix or a vector of the upper right 15 values.

# upper right triangle correlation specification
# inc and con have r = 0.5 within each difficultly level, 0.2 otherwise
#          ce,  ie,  cm,  im,  ch,  ih
triangle <-  c(0.5, 0.2, 0.2, 0.2, 0.2, #con_easy
                    0.2, 0.2, 0.2, 0.2, #inc_easy
                         0.5, 0.2, 0.2, #con_med
                              0.2, 0.2, #inc_med
                                   0.5) #con_hard
                                        #inc_hard

r <- list(
  novice_day = triangle,
  novice_night = triangle,
  expert_day = triangle,
  expert_night = triangle
)

You can set long = TRUE to return the data frame in long format, which is usually easier for plotting.

df <- sim_design(within, between, n = 100, 
                 mu = mu, sd = 2, r = r, 
                 dv = c(rt = "Reaction Time"), 
                 plot = FALSE, long = TRUE)

head(df)
#>     id experience time condition version    rt
#> 1 S001     novice  day       con    easy  9.61
#> 2 S002     novice  day       con    easy  9.34
#> 3 S003     novice  day       con    easy  8.15
#> 4 S004     novice  day       con    easy 11.59
#> 5 S005     novice  day       con    easy  7.54
#> 6 S006     novice  day       con    easy 11.73

Multiple datasets

You might want to make multiple datasets with the same design for simulations. It can be inefficient to just put sim_design() in an apply function or a for loop (especially if you leave plot = TRUE). The patterns below make this faster.

rep argument

You can simulate multiple datasets by setting the rep argument of sim_design() to a number greater than 1. This will return a nested data frame with one column called rep and another column called data, that contains each individual data frame. This method is faster than repeatedly calling sim_design(), which will check the syntax of your design each time, and returns a nested dataset that makes it easy to apply the same analysis to each replicate.

The code below creates 5 data frames with a 2W*2B design.

df <- sim_design(within = 2, between = 2, 
                 n = 50, mu = c(1, 1, 1, 1.5), 
                 sd = 1, r = 0.5, plot = FALSE, 
                 long = TRUE, rep = 5)

df
#>   rep
#> 1   1
#> 2   2
#> 3   3
#> 4   4
#> 5   5
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   data
#> 1            S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0.823628416606036, 1.04947775580423, 2.14830047764618, 1.2746143971463, 1.85528774323286, 0.287939677300414, -1.27415818354606, 1.35855179067829, 0.903614515067483, 1.12671889162066, 0.353474382511494, 1.20954835734338, 1.89912794546735, 1.35203136557311, 2.1778106637565, 0.451015637372707, 2.31046707184244, -0.888552646978253, 0.72149642539336, -0.669736179991179, 0.769872970303931, 1.20474880438577, 1.37968594771501, 0.240252828701029, 0.50185382952182, 0.44855979013257, 1.15458135761622, 1.3566380728204, 1.70198218026366, 0.754409303867608, 0.694858402572212, -0.273090219641491, -0.245883352029218, 0.0802483363202747, -0.25998108734952, 1.20445939086955, 0.837588857408504, -0.0994548351456142, -0.371990312540926, 1.95394843334331, 0.119557697448772, 0.840296366318227, 0.564219478920604, -0.169958089890487, 1.04128828676752, 2.05358703106541, 0.330591650499939, 0.290976662359473, 2.22606719773034, 1.63952582998424, 1.36110578262358, 1.81680440451965, 2.08567609750736, 1.16649125163109, 1.03160165204683, 1.51589513092244, 0.688866730527635, 0.330481547665992, 1.05337427336241, 2.89128544728883, 1.09803816918536, 2.59603752908679, 3.27721369070762, -0.0197106839195025, 0.992087370598539, 2.22000991912815, 0.278801046148988, -1.04299701393165, 2.11240965152578, -0.315332071101054, 2.33207963166107, 0.547941301633339, 2.85417747031179, 1.03741353356912, 0.725190043569734, 1.52037837047341, 1.15865622411926, 0.375213759851367, 2.19144331741016, -0.0719439849573331, 1.15291306563139, 0.752495033684313, 1.48462290848953, 0.785400153053635, 0.402325303408856, 1.90031589608581, 2.00698734577334, 2.58434245812388, 0.0471156655267447, 1.00138217081603, -0.533397534037533, 0.897328379823144, 1.119312040762, 2.57769083116132, 0.364739008436025, 0.735669130080452, 2.7898897544857, -0.429289201622085, 2.59767391322935, 0.0220715593972221, 1.42812632814137, 1.83180834945825, 2.64162416822216, 0.212839425921167, 2.24875193767116, 1.22786654052047, -0.188304336636493, 2.5696922567609, 1.58161994529385, 0.404785156091983, 1.07639480873454, 1.93495974279469, 0.0948050906749599, 1.03280358196676, 0.0753688565096863, 1.04452915854102, 1.88942971006669, 0.625224368661162, 1.73127378137021, 1.28363253679448, 0.673196841819345, 1.04864492482672, 0.461438348496473, 0.986367086001815, -0.211442452191251, 1.28667862271651, -0.110032234471713, -0.0947216795574568, 2.1686629710495, 0.275433394090764, -0.176141163688576, -0.574154094435054, -0.960123019911506, -0.975125226852169, 1.76424174921601, 1.18195181449038, 0.770030114124141, 0.312944956892903, 0.416400233385417, 1.94574445806849, -1.17892799703716, 1.73827512620301, 0.375855960938711, 1.18768790361655, 1.54069496704814, 0.326973544732288, 0.439392210654003, 0.073356333081424, 0.516475961724828, 0.914867537592882, 1.99746734949878, 1.85616256296007, 2.02083527576117, 1.97394463939547, 0.646851279799486, 1.41004654431424, 2.57452245155355, 2.862770251989, 2.37656180852146, 2.81359435224678, 2.90271372803568, 4.24607694141317, 2.56824427297405, 2.44821346577655, 1.90329274465825, 1.52160314267697, 0.883615478398367, 0.46297273564758, 3.09078322946075, 0.0890925281198609, 1.70389349506644, 0.548169024441266, 2.59595777336759, 1.48315485280796, 1.30629470392602, 1.71339526948514, 1.4296509635746, 1.1968885644779, 0.426794630739931, -0.0567084559451141, 1.376783160249, 1.18483730604954, 0.71919921099173, 0.189789684221004, 0.0747130429313805, 1.85368037073154, 4.08709192712577, 1.01974252859095, -0.674030240437482, 0.737642837155642, -0.587726221725291, 0.0581842238237242, 0.42808908803952, 2.0560740961566, 2.16921532062153, 0.975203201587821, 0.124257751487148, -0.72530985168842, 1.03518732483913, 1.029223113283
#> 2    S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.90465229732828, 1.06198784411447, -1.11993218857811, 0.10242812527078, -0.851647815261025, 3.17117992735718, 2.67709080859294, -0.930150861728016, 1.17585719528139, -0.343487427451215, 1.33991145588199, 0.918930239273988, 1.38010508577914, 1.28945122292931, -0.065455607974511, 2.6552426764415, 2.63750888770195, 0.749008148851663, -0.127844636693301, 0.958155681939372, -0.944154614445071, 0.0710215710963019, -0.401764310467773, -0.865460826185294, -0.0184753076039441, 2.3899277037351, 0.907444731029447, 0.861376532762667, 2.4604006232517, 2.95818582912113, 0.619097698737209, -0.110836004144444, -0.323162882406991, 0.473686499983562, 1.37097524031067, 1.23182645854664, 1.83777054900764, 1.44070370739898, 1.31361693710181, -0.0137106899245247, 1.8399173900601, 0.0812437106573605, 0.34424511093412, 0.237446739868993, 0.946574602328317, 1.55686402952348, 0.673138543684497, 0.132403127996968, 0.789356383015864, -0.696622019463734, 1.65631812715454, 1.77105895200328, 1.17996076387191, 0.373869402280734, 1.02586355081287, 0.694893062115468, 3.35665857817994, 1.95223086788051, 0.130890281076721, 2.01523883715557, 2.62966939824132, 2.73726960164887, 1.13084464016922, 0.708515621742369, 2.07789990148477, 1.36370803258267, 2.63272560167718, 0.883272356853168, 0.611053859244452, 0.64420148060547, 1.264210420005, -0.0537151911755669, -0.449965354997748, 0.885924663246442, 0.566284955480372, 2.21140638635234, 0.93305588032562, 1.14270520563204, 1.39482892569309, 1.15404250926349, 0.78391613183892, 2.33673913140353, 1.38039127840802, 2.72238567112031, 2.93115786210439, -0.866154402912144, -0.812316368059252, 1.63864879593345, 0.597713575840404, 1.44671608752152, 1.99647052468985, 1.88622662158374, 0.899859571603906, 0.710873362886771, 0.441183190706073, 0.671481416640846, -0.0817108705961334, 0.322575188368267, 0.231564191621544, 3.14406672620753, 1.42291481377734, 1.92046190790218, -0.54809953951236, -1.33960373079946, 0.415128346254614, 1.07813733079041, 1.21011513696181, 0.0691247143161282, -0.254278672794543, 0.50225627448203, 0.685962782349445, 2.72497446167223, 2.39754377596228, 0.410593212203332, 0.341317866799366, 1.19580679192877, 1.6268446613244, 2.46402195242323, 0.571513821838305, 1.83733807723985, -0.319479650862979, 0.766003368330817, 0.306461952369043, 0.230875177783035, 1.2736666384873, 1.93333641621109, 1.83080748042965, 1.20677449603872, 2.22583038747998, 1.71975891005644, 1.85539009020169, 0.237130019626108, 0.142156838274743, 1.46858387111842, 1.71627887560387, -0.0923515385599889, 0.767649774454755, 1.19603256795815, 1.01844421697097, 0.760156729085601, 1.93824700607915, 1.35322813416232, 1.09466562856273, -0.0799817017628586, 0.637771368724645, -0.052353217990607, -0.147804185065258, -0.197415121737115, 1.42754558327861, -0.522921002376816, 2.20941961568005, 2.78294055957259, 0.472966226025793, 0.351779052096493, 1.34474587605048, 1.26859190535215, 1.79551256708872, 2.74107948209215, 1.642726717989, 1.67748231945323, 2.46597650743427, -0.148492406484585, 0.267729233234942, 1.14799802339491, 3.15117044291975, 1.71500570620158, 2.61072144604461, 1.62330464812291, 0.24326661543679, 1.89653061434271, 1.25477377972854, -0.638562031383791, 0.323076526188073, 2.31952878593284, 2.12317362913381, 1.34194256664925, 1.28396417550097, 1.63274147222502, 1.85193603750414, 1.93624715220635, 2.16305511162732, 3.60993486166158, 2.29342358616731, 1.96576969922615, 2.6473893957396, 0.0870145873234263, -0.219903223950104, 0.720768921720583, 1.22943688315488, 1.69224444719971, 2.46979494140074, 1.24554263474835, 1.48073646336263, 0.201056478818837, 0.0870052993966877, 1.46737086460298, -0.0621263034376274, 0.851661850192684, 1.83673370195333, 2.5315240256722
#> 3          S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1.9737450918103, 1.64320906841127, 0.958676179557793, 0.294754067057176, -0.112546834606141, -0.201173472840118, 1.49795020202022, 1.45795373282259, 0.0385146042864689, 0.287447187570144, 0.380138179924483, 1.63603622022354, 0.748738273851613, 0.174412420674836, 1.94500766667424, 0.156739459323396, 2.07760410858934, 2.3236660616101, 0.0654116822593307, 2.20543010681263, 0.558884611299277, 1.00204635812021, 1.37344218397735, 0.31659323481872, 0.799269775778175, -0.656969665362632, 1.66855447294793, -0.210377597021361, 1.3106759388556, 1.66527539621559, 0.801839268171165, 1.20968016790627, 0.905106373028091, -0.752754443229771, 0.943893012815787, 0.915889636924835, 1.16391721595452, 1.57115168787737, 1.56858534538085, 1.06244886426909, 0.396278003390966, 2.17481515871821, 1.0303292837572, 1.9512571334894, 1.30980025270411, 0.690248942574886, 4.94860054846248, 1.20439258847645, -0.354697073697517, -1.57562689714456, 0.418332710178813, 1.44143583649402, -0.0279331287363278, 1.71913335238061, 0.761008632164523, 0.911907366447158, 0.860476400950227, 1.07332614379804, -0.0707820511345212, 0.967791773527854, 0.372930811416405, -0.861923171304875, 0.127699798404964, 0.513548510247477, 0.343708177492247, -0.069482468898433, 2.101115779921, 0.398077149501514, 0.448135406734009, 0.820790408530792, 0.90407612564314, 1.29041508591675, 1.79209342832725, 1.6747957971092, 2.88851921104752, 1.67127512092513, 1.64366109603636, 0.996146079905438, 2.63919884185081, 0.0593736664465006, 3.17472553605963, 2.93218238306114, 1.1257449602024, 0.515697667081752, 2.42064765757116, 1.76851386693002, 0.686115511981994, 1.21485084395878, -1.67605600564177, 1.73794934274063, 0.225157086889011, 1.72805611336854, -1.41097996813186, 0.166324099135176, 1.06231317742006, 1.02478719546407, 0.941554762018201, 0.886087284972219, 1.68378657046218, 0.534075372070759, 0.0769958145717444, 0.870687019548965, 0.886569709949101, 0.663422318749611, 1.18373933864069, 0.0232502180595517, 2.24546932264582, 0.210001155932983, 0.264462958686605, 0.525044734783659, 1.97635622586246, -0.283312285948857, -0.0466883104342943, 1.42288546102119, 1.47642658830485, 0.133982785502962, 1.21755298503097, 2.67315349148364, 0.371391155097052, 0.716624796288705, 0.310002147447957, 0.0512183426905735, 1.61611037794153, 0.134652439622188, 0.90690160417093, 1.37639459100847, 0.834840850201426, 0.476586219882975, 0.876753394144688, 1.40004121923938, 1.4385504743226, -0.242384830035351, -0.0936999265519012, -0.321207251585891, 2.31684685023459, 1.83037859770428, 0.0103174190381249, 1.01112069132805, 0.253528027050705, 1.07051035614793, 1.3014462028851, 1.53025587981684, 1.64496339460888, 2.19695554982165, 1.44204992420213, 0.681328174173575, 2.68997237989256, 1.2285065120897, 0.695507528045564, -1.05403669535038, 1.7116695010068, 1.55753699721284, 0.931532302627625, 0.892171541726528, 1.09587938231459, 1.19176109090001, 0.698063345659408, 0.796335246675921, 0.528059817407198, 0.993186938215116, 2.06166568699501, 2.28723159296839, 2.11891742177647, 1.90007237252346, 0.649820317671236, 0.931355170985388, 1.16459881336835, 2.84618374008527, 2.19779051507682, -0.71520374558115, 1.21107518490257, 0.691884844901935, 2.27825898961737, 1.16481196373126, 3.93974046754938, 3.26703070843019, 3.12936126376486, 1.87383282035814, 1.82923528839767, -0.211735484159459, 3.79570786692933, 1.63977943370158, 0.731736425377912, 1.72718404539228, 2.54888073310448, 2.36666705532102, 1.68692635016056, 1.08085321085718, 0.571589731702317, 0.320904956811594, -0.123411091029727, 2.8265953050602, -1.15163182879684, 2.63108930653715, 1.28586646202123, 2.63390687209281, 0.216384383454463, 2.65994666732998, 2.30064601518556, 2.11950251627486
#> 4                                  S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0.390996737022794, 0.514419279322078, 0.465219941640955, 3.11701542636532, 0.544508779491317, 1.26640342605438, 0.709468434016184, 0.484091606530019, 0.340539327010012, 2.12816657988586, 0.526209660745157, 4.11955918681923, 0.586072991553786, 0.445353388305301, 1.2873722573024, 2.42438100691483, 1.46376969611168, 0.244762961808145, 0.992138814536005, 1.60642717441871, 0.538123401841899, 0.0520964369671474, 2.3940425280377, -0.10812510122673, 2.69834325728841, 2.47191522038167, 1.70335072085337, 2.12887526887032, 0.109412156214895, 2.39913712451626, 0.422345527805536, 0.30639868683018, 1.62093820625479, 1.38401069001983, 1.38952311927667, 1.73279772123413, 1.48328138825603, 3.26329836805232, 3.04693384236406, 0.824473231486417, 0.885141996232264, 1.6606545062688, 2.59548844818765, 1.75364937350649, 1.38058410232143, 1.39653311665508, 1.07671098458765, -0.240137130147369, 2.33861232245748, 0.524135561249644, 0.821194691692955, 1.00171076830003, -0.788958644559531, 1.72205053035894, 1.95019581302341, -1.75211040818413, 1.67495167058991, 0.530876972948112, -0.773195598832142, 0.670528408487344, 0.530897768872627, 2.93232396847259, 1.18433869678288, 0.206317111442945, 0.627277699948352, -0.125484460442242, 2.13128060856378, 2.40178193039027, 0.14264046642039, 0.688007299088954, 1.50221960058724, 3.05611986163872, 0.507409391923066, 0.50014671867989, 0.329414866172453, 0.375249435746574, 1.99288730939544, 2.22757555228064, 1.25644770007495, -1.19489410365346, 1.9729220247366, 1.59073470778152, 0.112214778600658, 2.56296082138495, 2.40843012347995, 1.82161350871862, 2.49908459645729, -0.0660931867045258, 0.794847035690629, -0.0279214365944875, 1.49282759605946, 2.51887477996389, 0.303306762375942, 3.08205144041933, 0.965129427962902, 2.20452112879489, 0.675904589942106, 1.01629357199723, 0.0757747164006191, 2.87673218842204, 1.80706953821955, 0.112349601830626, 0.889576594319076, 3.23924763347067, 1.41234686276884, 2.91733964106671, -0.540123510184444, -0.0722300541322409, 0.242944347089705, 1.62368508335076, 1.71282694532638, 2.52503981722833, -0.469895996129148, -0.3399012383782, 0.821157755788413, 1.21211609539506, -0.656061212239198, 0.260009604272351, 0.585975452392078, 2.34563582174388, 0.241786060637767, -0.955628614675378, 0.286133672767774, 0.128647112456209, 2.66439296745249, 2.21504152597742, 1.85192628707628, 0.954779196420469, 0.851312800839909, 1.73615771942524, -0.259875702852075, 0.79563883733003, 1.96980049479768, 2.14284616963924, 0.740454361686355, 1.39041287644043, 2.21889790881344, 1.98804601079687, 1.62167543173107, 1.76704974044433, 0.68066488343528, 0.597515070229046, 2.26728221582283, 1.34308906106656, 1.52427451863171, 2.34570853078019, 1.16521984857001, 0.598396492444016, 2.6518136907934, 0.753180837150408, 1.98132637774831, 1.06056822187545, 0.496894518169738, 0.723168221627451, 2.3862145904786, 0.46598433377952, 2.61939620009976, 2.08246382528877, 1.12884724884493, 1.43479191708313, 0.56514850543195, 1.500884252108, 3.4389201262876, 2.22532226264786, -0.566105049094095, -0.400617203104187, 1.19544869077937, 2.58837268506061, 1.61630764483899, 2.80649984607692, 2.63043262439607, 1.05777389527377, 2.69908701788188, 1.32700894914053, 1.72148809914738, 0.703069282348873, 2.65255437281893, 2.67604032597864, 2.37044918275909, 0.332395475810734, 2.95554256560293, 2.61711303339079, 1.03952339983093, 2.48095970276917, 1.03064469012436, 3.26327110809061, 1.32943769209757, 0.24527908086878, 2.22153278482233, 0.169005762196623, -0.336406939332894, 3.08851131198831, 0.759081882205124, 2.24000933805869, 1.84716178368636, 2.29595154065351, 2.53493545171893, 2.11185580974179, 1.44669225916909, 1.99719258745106
#> 5 S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, S001, S002, S003, S004, S005, S006, S007, S008, S009, S010, S011, S012, S013, S014, S015, S016, S017, S018, S019, S020, S021, S022, S023, S024, S025, S026, S027, S028, S029, S030, S031, S032, S033, S034, S035, S036, S037, S038, S039, S040, S041, S042, S043, S044, S045, S046, S047, S048, S049, S050, S051, S052, S053, S054, S055, S056, S057, S058, S059, S060, S061, S062, S063, S064, S065, S066, S067, S068, S069, S070, S071, S072, S073, S074, S075, S076, S077, S078, S079, S080, S081, S082, S083, S084, S085, S086, S087, S088, S089, S090, S091, S092, S093, S094, S095, S096, S097, S098, S099, S100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0.486725659372221, 1.64357556082774, 0.263194494557383, 1.0296548031938, 0.811726875438496, 0.5976157581421, 1.90602786838901, 1.28057058318111, 1.56624339125893, 0.998155969775003, 0.00170289563711612, 0.509547462735587, -0.00706356580588374, -0.797435868547153, 1.13284344760021, 1.03035461094415, 1.10535438489287, -0.197824348260161, 1.75269621759939, 1.72800465262085, 1.76707520038246, 0.851881340610244, 1.54363125075404, 1.85215533890089, 0.594390665563255, 2.35970532918645, 0.947998324970383, 0.81567240073653, 0.332835046674711, 0.620404809444938, 1.78989750836414, 2.02759270156495, 2.54545630808485, -0.828374732911002, -0.801094510975028, 1.08107571453343, -1.21899807157319, 0.37450302180007, 1.18473667818687, -0.166122980632638, 0.159384167235982, -0.922610427995531, -0.832063998534347, 0.387313458504679, 0.670837122851231, 3.39890689453518, 0.685587046958218, 0.137996866146473, 2.75580651598626, 0.381296723364541, -0.571471926350737, 1.56372990933579, 0.811422647695064, 1.74820580179273, 1.06426592792395, 1.45976091883044, 0.0632732127200647, -0.656127063017977, 1.63700995639338, 2.74432467786927, 0.0881414374420042, 0.861670915448589, -1.48247489988499, 1.43163376124232, 2.14987611850804, 0.226800595386425, 0.901575222264706, 0.859722443799302, 1.00484933846561, 0.413386452147952, 1.50345968290061, -0.0209971611468218, 0.945624780088165, 1.39596168009528, 2.11555398525582, 0.969177721547276, 0.33167730810068, 0.848772768889905, 1.53101851479371, -1.04671261247307, 0.522985902823807, -0.222720595890356, 0.885180815996636, 2.93302537522913, -0.199168974987085, 0.667713043850799, 1.24269930424188, -0.363755940323252, 1.96356421280043, 2.17718086781351, 0.332970913207297, 2.93843475564905, 0.327973766128561, -0.0247523761572936, 0.906337422630317, 3.03178302946813, -0.079281092050191, 2.40821815755792, 1.00828963972639, 1.52366884910225, 0.752723204745463, 2.54143078897211, 1.63348422870709, 1.49668266374234, 1.56191299075821, 1.90084447585914, 1.19130863286561, 1.23380201228986, 1.07177867507661, 0.990674913375293, 1.2029157469686, 0.942211223315491, 1.077593960246, 1.692175031131, 1.63680871096879, 2.23186244841482, 1.51016555011943, 0.298784108846654, 2.39172384433106, 0.926277183435013, 3.60965377132057, 0.357507986215217, 1.19820585650051, -0.0815578789434006, 1.20773770169254, 2.30332999548949, 0.615194661374982, 0.60178399709971, 0.061198013531931, 1.11195739753951, 1.87050391331559, 1.77392005091269, 1.10592976678195, -0.492546742240126, -0.996543170563963, -0.0743749228705897, -1.26406223534939, 0.117735044120884, 2.71285713441115, -0.0316282020028198, 0.410455710338117, 0.173880619460838, 0.714667321650425, 1.03675268218041, -0.231031745450341, 3.14028996613381, -0.175721448321136, 0.930082019065776, 2.64735159540688, 1.18845643623468, -0.630265793191784, 0.935619809552062, 0.460192276556114, 2.8485302708645, 1.87192007126775, 1.59236896995704, 1.364872838976, -0.022774803626495, 1.71767714223523, 1.80575660305377, 2.54316072533052, 1.84593828861636, -1.66331966871552, 1.96958863560675, 2.52384276217459, 1.00190361237165, 1.65407460075167, 1.78667552036777, 1.33320784401231, 0.605333408261912, 3.45962136980245, 0.244187071485811, 2.10622652276742, 2.40770063778364, 2.2704631768497, 0.849843375257935, 0.774647774582052, 1.81455437244012, 1.89079024112148, 0.318784320738019, 1.74159036091936, 0.840666949567401, 1.81279632464054, 3.77251434407046, -0.346018184183341, 1.70069180204209, 0.834905078486252, 0.255960460856275, 1.31640195037946, 1.25880932188798, 1.14145511912438, 1.45723490194377, -0.0818208655607746, 1.13210993968314, 1.76896305566814, 3.48572911798513, 1.41233612186743, 2.82461287595284, 0.766380639932241, 2.04150889429403

You can access an individual data frame using df$data[[1]] or run the same function on each data frame using a pattern like below:

# using tidyverse functions
analyse <- function(data) {
  stats::aov(y ~ B1 * W1 + Error(id/W1), data = data) %>% 
    broom::tidy()
}

df %>%
  dplyr::mutate(analysis = lapply(data, analyse)) %>%
  dplyr::select(-data) %>%
  tidyr::unnest(analysis)
#> # A tibble: 25 × 8
#>      rep stratum term         df   sumsq meansq statistic  p.value
#>    <int> <chr>   <chr>     <dbl>   <dbl>  <dbl>     <dbl>    <dbl>
#>  1     1 id      B1            1  11.9   11.9       8.52   0.00436
#>  2     1 id      Residuals    98 137.     1.40     NA     NA      
#>  3     1 id:W1   W1            1   0.550  0.550     1.01   0.316  
#>  4     1 id:W1   B1:W1         1   0.464  0.464     0.855  0.357  
#>  5     1 id:W1   Residuals    98  53.2    0.542    NA     NA      
#>  6     2 id      B1            1  12.4   12.4       8.03   0.00558
#>  7     2 id      Residuals    98 151.     1.54     NA     NA      
#>  8     2 id:W1   W1            1   1.39   1.39      3.18   0.0776 
#>  9     2 id:W1   B1:W1         1   0.266  0.266     0.611  0.436  
#> 10     2 id:W1   Residuals    98  42.8    0.436    NA     NA      
#> # ℹ 15 more rows

Unnested reps

You can also get an unnested data frame by setting nested = FALSE. This is a bit faster to return, but less useful for the pattern above.

df <- sim_design(within = 2, between = 2, 
                 n = 2, mu = c(1, 1, 1, 1.5), 
                 sd = 1, r = 0.5, plot = FALSE, 
                 long = TRUE, rep = 2, nested = FALSE)

df
#>    rep id  B1  W1      y
#> 1    1 S1 B1a W1a -0.615
#> 2    1 S2 B1a W1a  1.582
#> 3    1 S3 B1b W1a -0.930
#> 4    1 S4 B1b W1a  0.957
#> 5    1 S1 B1a W1b -0.270
#> 6    1 S2 B1a W1b  1.461
#> 7    1 S3 B1b W1b  2.063
#> 8    1 S4 B1b W1b  2.599
#> 9    2 S1 B1a W1a  0.740
#> 10   2 S2 B1a W1a  1.533
#> 11   2 S3 B1b W1a  0.253
#> 12   2 S4 B1b W1a  2.118
#> 13   2 S1 B1a W1b -0.389
#> 14   2 S2 B1a W1b  1.684
#> 15   2 S3 B1b W1b  1.967
#> 16   2 S4 B1b W1b  2.509

Simulate by design

The check_design() function converts any abbreviated design specification to the fully expanded version; it checks your design specification when you run sim_design() or you can run it on its own to create a validated design list.

between <- list(pet = c("cat", "dog"))
within <- list(time = c("day", "night"))
vardesc <- c(pet = "Type of Pet",
             time = "Time of Day")
design <- check_design(within, between, n = 10, 
                       mu = 1:4, sd = 1:4, r = 0.5, 
                       vardesc = vardesc, plot = FALSE)

design
  • [DV] y: value
  • [ID] id: id
  • Within-subject variables:
    • time: Time of Day:
      • day: day
      • night: night
  • Between-subject variables:
    • pet: Type of Pet:
      • cat: cat
      • dog: dog
  • Parameters: |pet |time | day| night| n| mu| sd| |:—|:—–|—:|—–:|–:|–:|–:| |cat |day | 1.0| 0.5| 10| 1| 1| |cat |night | 0.5| 1.0| 10| 2| 2| |dog |day | 1.0| 0.5| 10| 3| 3| |dog |night | 0.5| 1.0| 10| 4| 4|

You can then use the design object to create simulated datasets. If you set the design for sim_design() with the design argument instead of specifying parameters, it will skip the time-consuming checks, which can speed up simulations by 30% or more.

data <- sim_design(design = design)