sim_mixed_df() produces a data table with the same distributions of by-subject and by-item random intercepts as an existing data table.

sim_mixed_df(data, sub_n = NULL, item_n = NULL, dv = "y",
  sub_id = "sub_id", item_id = "item_id", seed = NULL)

Arguments

data

the existing tbl

sub_n

the number of subjects to simulate (if NULL, returns data for the same subjects)

item_n

the number of items to simulate (if NULL, returns data for the same items)

dv

the column name or index containing the DV

sub_id

the column name or index for the subject IDs

item_id

the column name or index for the item IDs

seed

a single value, interpreted as an integer, or NULL (see set.seed)

Value

a tbl

Examples

sim_mixed_df(faceratings, 10, 10, "rating", "rater_id", "face_id")
#> # A tibble: 100 x 7 #> sub_id item_id y grand_i sub_i item_i err #> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 S01 I01 2.40 3.02 -1.49 1.11 -0.242 #> 2 S01 I02 3.19 3.02 -1.49 0.442 1.22 #> 3 S01 I03 2.42 3.02 -1.49 -0.629 1.52 #> 4 S01 I04 2.57 3.02 -1.49 0.236 0.801 #> 5 S01 I05 1.09 3.02 -1.49 0.446 -0.888 #> 6 S01 I06 2.32 3.02 -1.49 0.297 0.486 #> 7 S01 I07 3.97 3.02 -1.49 1.82 0.618 #> 8 S01 I08 3.02 3.02 -1.49 1.59 -0.103 #> 9 S01 I09 1.21 3.02 -1.49 0.0123 -0.337 #> 10 S01 I10 2.14 3.02 -1.49 -0.216 0.825 #> # … with 90 more rows