Skip to contents

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

Usage

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

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

Value

a tbl

Examples

sim_mixed_df(faceratings, 10, 10, "rating", "rater_id", "face_id")
#>     sub_id item_id           y  grand_i       sub_i      item_i         err
#> 1      S01     I01  2.29823723 3.018906  0.02692613  0.11610118 -0.86369569
#> 15     S01     I02  1.69520652 3.018906  0.02692613 -0.48902346 -0.86160175
#> 29     S01     I03  2.92421004 3.018906  0.02692613 -0.79376279  0.67214109
#> 31     S01     I04  2.30403256 3.018906  0.02692613 -0.34742010 -0.39437908
#> 44     S01     I05  2.93627260 3.018906  0.02692613 -0.26716949  0.15761035
#> 58     S01     I06  3.23312630 3.018906  0.02692613  0.09843036  0.08886421
#> 61     S01     I07  3.73486405 3.018906  0.02692613  0.40205042  0.28698189
#> 73     S01     I08  2.16576125 3.018906  0.02692613 -0.96395071  0.08388022
#> 87     S01     I09  2.97156544 3.018906  0.02692613 -0.31031411  0.23604781
#> 91     S01     I10  4.19076756 3.018906  0.02692613  0.54068543  0.60425040
#> 7      S02     I01  3.18483443 3.018906  0.02495687  0.11610118  0.02487077
#> 17     S02     I02  2.41601258 3.018906  0.02495687 -0.48902346 -0.13882645
#> 30     S02     I03  2.37446731 3.018906  0.02495687 -0.79376279  0.12436761
#> 36     S02     I04  2.73804413 3.018906  0.02495687 -0.34742010  0.04160174
#> 46     S02     I05  3.27872986 3.018906  0.02495687 -0.26716949  0.50203686
#> 59     S02     I06  2.31385700 3.018906  0.02495687  0.09843036 -0.82843584
#> 69     S02     I07  1.45471833 3.018906  0.02495687  0.40205042 -1.99119457
#> 75     S02     I08  2.54024061 3.018906  0.02495687 -0.96395071  0.46032883
#> 88     S02     I09  1.62246714 3.018906  0.02495687 -0.31031411 -1.11108124
#> 98     S02     I10  4.87775476 3.018906  0.02495687  0.54068543  1.29320684
#> 4      S03     I01  2.03985427 3.018906  0.64676110  0.11610118 -1.74191362
#> 18     S03     I02  3.56138741 3.018906  0.64676110 -0.48902346  0.38474416
#> 23     S03     I03  4.39542801 3.018906  0.64676110 -0.79376279  1.52352409
#> 33     S03     I04  2.28679085 3.018906  0.64676110 -0.34742010 -1.03145576
#> 47     S03     I05  4.16455951 3.018906  0.64676110 -0.26716949  0.76606229
#> 60     S03     I06  2.42755957 3.018906  0.64676110  0.09843036 -1.33653750
#> 62     S03     I07  4.42655258 3.018906  0.64676110  0.40205042  0.35883545
#> 76     S03     I08  2.13633792 3.018906  0.64676110 -0.96395071 -0.56537809
#> 89     S03     I09  3.12076250 3.018906  0.64676110 -0.31031411 -0.23459010
#> 95     S03     I10  4.00746981 3.018906  0.64676110  0.54068543 -0.19888232
#> 5      S04     I01  2.59899444 3.018906 -0.57622906  0.11610118  0.04021670
#> 19     S04     I02  1.40306658 3.018906 -0.57622906 -0.48902346 -0.55058652
#> 21     S04     I03  1.93921285 3.018906 -0.57622906 -0.79376279  0.29029908
#> 34     S04     I04  1.72507985 3.018906 -0.57622906 -0.34742010 -0.37017661
#> 48     S04     I05  0.74532284 3.018906 -0.57622906 -0.26716949 -1.43018423
#> 51     S04     I06  2.04734726 3.018906 -0.57622906  0.09843036 -0.49375965
#> 63     S04     I07  2.07541272 3.018906 -0.57622906  0.40205042 -0.76931426
#> 77     S04     I08  1.84805213 3.018906 -0.57622906 -0.96395071  0.36932628
#> 90     S04     I09  1.09847993 3.018906 -0.57622906 -0.31031411 -1.03388252
#> 92     S04     I10  4.32968518 3.018906 -0.57622906  0.54068543  1.34632319
#> 2      S05     I01  5.15208852 3.018906  1.02321698  0.11610118  0.99386476
#> 16     S05     I02  1.04189576 3.018906  1.02321698 -0.48902346 -2.51120337
#> 22     S05     I03  4.51714252 3.018906  1.02321698 -0.79376279  1.26878272
#> 35     S05     I04  5.90380951 3.018906  1.02321698 -0.34742010  2.20910702
#> 45     S05     I05  3.07651916 3.018906  1.02321698 -0.26716949 -0.69843393
#> 52     S05     I06  2.63303923 3.018906  1.02321698  0.09843036 -1.50751372
#> 64     S05     I07  6.58715007 3.018906  1.02321698  0.40205042  2.14297706
#> 74     S05     I08  4.69612636 3.018906  1.02321698 -0.96395071  1.61795448
#> 81     S05     I09  4.68282053 3.018906  1.02321698 -0.31031411  0.95101205
#> 93     S05     I10  4.54237225 3.018906  1.02321698  0.54068543 -0.04043576
#> 8      S06     I01  3.29097362 3.018906 -0.19924964  0.11610118  0.35521647
#> 20     S06     I02  1.89058074 3.018906 -0.19924964 -0.48902346 -0.44005177
#> 27     S06     I03  2.93256230 3.018906 -0.19924964 -0.79376279  0.90666912
#> 37     S06     I04  2.99909935 3.018906 -0.19924964 -0.34742010  0.52686348
#> 49     S06     I05  3.63923717 3.018906 -0.19924964 -0.26716949  1.08675069
#> 56     S06     I06  2.79101391 3.018906 -0.19924964  0.09843036 -0.12707242
#> 66     S06     I07  4.04987318 3.018906 -0.19924964  0.40205042  0.82816678
#> 79     S06     I08  3.28041345 3.018906 -0.19924964 -0.96395071  1.42470818
#> 85     S06     I09  0.94448015 3.018906 -0.19924964 -0.31031411 -1.56486171
#> 99     S06     I10  4.31929250 3.018906 -0.19924964  0.54068543  0.95895111
#> 9      S07     I01  2.00126785 3.018906 -0.40472244  0.11610118 -0.72901650
#> 11     S07     I02  1.24049709 3.018906 -0.40472244 -0.48902346 -0.88466262
#> 24     S07     I03  2.94931048 3.018906 -0.40472244 -0.79376279  1.12889010
#> 38     S07     I04  0.87686950 3.018906 -0.40472244 -0.34742010 -1.38989357
#> 50     S07     I05  2.00999175 3.018906 -0.40472244 -0.26716949 -0.33702193
#> 53     S07     I06  2.93732477 3.018906 -0.40472244  0.09843036  0.22471124
#> 67     S07     I07  2.88077889 3.018906 -0.40472244  0.40205042 -0.13545470
#> 80     S07     I08  2.01891202 3.018906 -0.40472244 -0.96395071  0.36867955
#> 82     S07     I09  0.25129826 3.018906 -0.40472244 -0.31031411 -2.05257080
#> 96     S07     I10  3.56501658 3.018906 -0.40472244  0.54068543  0.41014798
#> 6      S08     I01  3.95022296 3.018906 -0.26657310  0.11610118  1.08178928
#> 12     S08     I02  1.88161911 3.018906 -0.26657310 -0.48902346 -0.38168994
#> 25     S08     I03 -0.07453095 3.018906 -0.26657310 -0.79376279 -2.03310067
#> 39     S08     I04  1.48954876 3.018906 -0.26657310 -0.34742010 -0.91536364
#> 41     S08     I05  3.37057828 3.018906 -0.26657310 -0.26716949  0.88541527
#> 54     S08     I06  3.73767844 3.018906 -0.26657310  0.09843036  0.88691558
#> 68     S08     I07  2.00288074 3.018906 -0.26657310  0.40205042 -1.15150218
#> 78     S08     I08  1.94666720 3.018906 -0.26657310 -0.96395071  0.15828540
#> 83     S08     I09  0.93269002 3.018906 -0.26657310 -0.31031411 -1.50932838
#> 97     S08     I10  3.16102881 3.018906 -0.26657310  0.54068543 -0.13198913
#> 3      S09     I01  3.49240862 3.018906  1.06199098  0.11610118 -0.70458914
#> 13     S09     I02  3.09715552 3.018906  1.06199098 -0.48902346 -0.49471761
#> 26     S09     I03  3.80572038 3.018906  1.06199098 -0.79376279  0.51858658
#> 32     S09     I04  3.58987672 3.018906  1.06199098 -0.34742010 -0.14359977
#> 42     S09     I05  5.14184515 3.018906  1.06199098 -0.26716949  1.32811806
#> 55     S09     I06  4.90108097 3.018906  1.06199098  0.09843036  0.72175403
#> 65     S09     I07  4.33849069 3.018906  1.06199098  0.40205042 -0.14445632
#> 71     S09     I08  2.62027602 3.018906  1.06199098 -0.96395071 -0.49666987
#> 84     S09     I09  4.30703651 3.018906  1.06199098 -0.31031411  0.53645403
#> 94     S09     I10  3.51894703 3.018906  1.06199098  0.54068543 -1.10263499
#> 10     S10     I01  1.64995085 3.018906  0.14283506  0.11610118 -1.62789100
#> 14     S10     I02  2.44424467 3.018906  0.14283506 -0.48902346 -0.22847254
#> 28     S10     I03  1.09687472 3.018906  0.14283506 -0.79376279 -1.27110316
#> 40     S10     I04  3.40755146 3.018906  0.14283506 -0.34742010  0.59323089
#> 43     S10     I05  4.06702688 3.018906  0.14283506 -0.26716949  1.17245570
#> 57     S10     I06  2.82111334 3.018906  0.14283506  0.09843036 -0.43905769
#> 70     S10     I07  2.33983893 3.018906  0.14283506  0.40205042 -1.22395216
#> 72     S10     I08  1.34056163 3.018906  0.14283506 -0.96395071 -0.85722834
#> 86     S10     I09  2.46438036 3.018906  0.14283506 -0.31031411 -0.38704621
#> 100    S10     I10  3.80531274 3.018906  0.14283506  0.54068543  0.10288664