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"
)

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  5.8630738 3.018906 -0.02864418  1.8463207  1.02649165
#> 15     S01     I02  4.1052776 3.018906 -0.02864418  0.2516254  0.86339078
#> 29     S01     I03  1.3277349 3.018906 -0.02864418 -0.4985067 -1.16401983
#> 31     S01     I04  3.2448186 3.018906 -0.02864418 -0.3736621  0.62821925
#> 44     S01     I05  5.6536267 3.018906 -0.02864418  0.5256222  2.13774315
#> 58     S01     I06  2.5335070 3.018906 -0.02864418 -1.0786135  0.62185915
#> 61     S01     I07  2.3798874 3.018906 -0.02864418  0.7293346 -1.33970858
#> 73     S01     I08  1.4848256 3.018906 -0.02864418  0.3474490 -1.85288484
#> 87     S01     I09  2.7069998 3.018906 -0.02864418 -0.1462518 -0.13700984
#> 91     S01     I10 -0.6636221 3.018906 -0.02864418 -1.4821233 -2.17176018
#> 7      S02     I01  2.3180962 3.018906  0.31980001  1.8463207 -2.86693016
#> 17     S02     I02  3.6118813 3.018906  0.31980001  0.2516254  0.02155032
#> 30     S02     I03  2.6188081 3.018906  0.31980001 -0.4985067 -0.22139084
#> 36     S02     I04  3.9943759 3.018906  0.31980001 -0.3736621  1.02933238
#> 46     S02     I05  5.0975305 3.018906  0.31980001  0.5256222  1.23320272
#> 59     S02     I06  2.2458116 3.018906  0.31980001 -1.0786135 -0.01428054
#> 69     S02     I07  3.6628714 3.018906  0.31980001  0.7293346 -0.40516883
#> 75     S02     I08  1.4619587 3.018906  0.31980001  0.3474490 -2.22419597
#> 88     S02     I09  3.9004071 3.018906  0.31980001 -0.1462518  0.70795321
#> 98     S02     I10  3.1282936 3.018906  0.31980001 -1.4821233  1.27171128
#> 4      S03     I01  5.4340584 3.018906  0.35327723  1.8463207  0.21555486
#> 18     S03     I02  5.1526170 3.018906  0.35327723  0.2516254  1.52880876
#> 23     S03     I03  1.4583175 3.018906  0.35327723 -0.4985067 -1.41535863
#> 33     S03     I04  3.5708513 3.018906  0.35327723 -0.3736621  0.57233050
#> 47     S03     I05  4.9368915 3.018906  0.35327723  0.5256222  1.03908649
#> 60     S03     I06  1.3319849 3.018906  0.35327723 -1.0786135 -0.96158443
#> 62     S03     I07  0.7169031 3.018906  0.35327723  0.7293346 -3.38461432
#> 76     S03     I08  3.7460880 3.018906  0.35327723  0.3474490  0.02645614
#> 89     S03     I09  2.7817993 3.018906  0.35327723 -0.1462518 -0.44413178
#> 95     S03     I10  2.4666322 3.018906  0.35327723 -1.4821233  0.57657272
#> 5      S04     I01  7.1007230 3.018906  1.63263579  1.8463207  0.60286095
#> 19     S04     I02  3.9932387 3.018906  1.63263579  0.2516254 -0.90992811
#> 21     S04     I03  4.6948532 3.018906  1.63263579 -0.4985067  0.54181857
#> 34     S04     I04  2.9276694 3.018906  1.63263579 -0.3736621 -1.35020996
#> 48     S04     I05  5.4739966 3.018906  1.63263579  0.5256222  0.29683305
#> 51     S04     I06  4.2866641 3.018906  1.63263579 -1.0786135  0.71373626
#> 63     S04     I07  4.0540004 3.018906  1.63263579  0.7293346 -1.32687561
#> 77     S04     I08  5.2742477 3.018906  1.63263579  0.3474490  0.27525724
#> 90     S04     I09  2.2229647 3.018906  1.63263579 -0.1462518 -2.28232492
#> 92     S04     I10  1.4114730 3.018906  1.63263579 -1.4821233 -1.75794507
#> 2      S05     I01  5.8016953 3.018906 -0.86294483  1.8463207  1.79941384
#> 16     S05     I02  1.5901865 3.018906 -0.86294483  0.2516254 -0.81739966
#> 22     S05     I03  1.9039409 3.018906 -0.86294483 -0.4985067  0.24648684
#> 35     S05     I04  2.8124204 3.018906 -0.86294483 -0.3736621  1.03012167
#> 45     S05     I05  2.0877693 3.018906 -0.86294483  0.5256222 -0.59381360
#> 52     S05     I06  1.6617123 3.018906 -0.86294483 -1.0786135  0.58436501
#> 64     S05     I07  1.6372491 3.018906 -0.86294483  0.7293346 -1.24804625
#> 74     S05     I08  3.1311317 3.018906 -0.86294483  0.3474490  0.62772190
#> 81     S05     I09  2.1671446 3.018906 -0.86294483 -0.1462518  0.15743552
#> 93     S05     I10 -0.4008950 3.018906 -0.86294483 -1.4821233 -1.07473243
#> 8      S06     I01  5.9257844 3.018906  0.03959823  1.8463207  1.02095989
#> 20     S06     I02  2.4758270 3.018906  0.03959823  0.2516254 -0.83430223
#> 27     S06     I03  2.2972496 3.018906  0.03959823 -0.4985067 -0.26274756
#> 37     S06     I04  2.2350734 3.018906  0.03959823 -0.3736621 -0.44976842
#> 49     S06     I05  2.1702193 3.018906  0.03959823  0.5256222 -1.41390668
#> 56     S06     I06  3.6262086 3.018906  0.03959823 -1.0786135  1.64631831
#> 66     S06     I07  4.1091339 3.018906  0.03959823  0.7293346  0.32129548
#> 79     S06     I08  1.4201049 3.018906  0.03959823  0.3474490 -1.98584802
#> 85     S06     I09  2.1952018 3.018906  0.03959823 -0.1462518 -0.71705027
#> 99     S06     I10  1.7417325 3.018906  0.03959823 -1.4821233  0.16535201
#> 9      S07     I01  4.5474096 3.018906  0.96796620  1.8463207 -1.28578294
#> 11     S07     I02  4.1371962 3.018906  0.96796620  0.2516254 -0.10130105
#> 24     S07     I03  4.5331687 3.018906  0.96796620 -0.4985067  1.04480363
#> 38     S07     I04  3.1815648 3.018906  0.96796620 -0.3736621 -0.43164500
#> 50     S07     I05  4.8434686 3.018906  0.96796620  0.5256222  0.33097464
#> 53     S07     I06  2.5239594 3.018906  0.96796620 -1.0786135 -0.38429888
#> 67     S07     I07  5.2229683 3.018906  0.96796620  0.7293346  0.50676188
#> 80     S07     I08  5.8293525 3.018906  0.96796620  0.3474490  1.49503162
#> 82     S07     I09  3.3060265 3.018906  0.96796620 -0.1462518 -0.53459360
#> 96     S07     I10  2.6724356 3.018906  0.96796620 -1.4821233  0.16768713
#> 6      S08     I01  3.3157825 3.018906 -1.32322433  1.8463207 -0.22621946
#> 12     S08     I02  2.1747276 3.018906 -1.32322433  0.2516254  0.22742097
#> 25     S08     I03  2.1873936 3.018906 -1.32322433 -0.4985067  0.99021903
#> 39     S08     I04  1.3019561 3.018906 -1.32322433 -0.3736621 -0.02006311
#> 41     S08     I05  2.3707683 3.018906 -1.32322433  0.5256222  0.14946486
#> 54     S08     I06  0.5262679 3.018906 -1.32322433 -1.0786135 -0.09079984
#> 68     S08     I07  2.6986386 3.018906 -1.32322433  0.7293346  0.27362280
#> 78     S08     I08  2.7853438 3.018906 -1.32322433  0.3474490  0.74221349
#> 83     S08     I09  2.0360006 3.018906 -1.32322433 -0.1462518  0.48657106
#> 97     S08     I10 -0.9478085 3.018906 -1.32322433 -1.4821233 -1.16136644
#> 3      S09     I01  6.2990963 3.018906 -0.22130921  1.8463207  1.65517919
#> 13     S09     I02  1.0725489 3.018906 -0.22130921  0.2516254 -1.97667293
#> 26     S09     I03  2.8503823 3.018906 -0.22130921 -0.4985067  0.55129266
#> 32     S09     I04  1.3670136 3.018906 -0.22130921 -0.3736621 -1.05692074
#> 42     S09     I05  2.6601664 3.018906 -0.22130921  0.5256222 -0.66305216
#> 55     S09     I06  2.4123244 3.018906 -0.22130921 -1.0786135  0.69334150
#> 65     S09     I07  2.9912134 3.018906 -0.22130921  0.7293346 -0.53571761
#> 71     S09     I08  3.9697993 3.018906 -0.22130921  0.3474490  0.82475384
#> 84     S09     I09  3.5059682 3.018906 -0.22130921 -0.1462518  0.85462354
#> 94     S09     I10 -0.5976865 3.018906 -0.22130921 -1.4821233 -1.91315961
#> 10     S10     I01  3.7615201 3.018906  0.50621891  1.8463207 -1.60992511
#> 14     S10     I02  3.8918622 3.018906  0.50621891  0.2516254  0.11511230
#> 28     S10     I03  3.4227492 3.018906  0.50621891 -0.4985067  0.39613144
#> 40     S10     I04  4.3611958 3.018906  0.50621891 -0.3736621  1.20973338
#> 43     S10     I05  3.7338272 3.018906  0.50621891  0.5256222 -0.31691948
#> 57     S10     I06  2.7110698 3.018906  0.50621891 -1.0786135  0.26455878
#> 70     S10     I07  4.8558599 3.018906  0.50621891  0.7293346  0.60140082
#> 72     S10     I08  4.2008346 3.018906  0.50621891  0.3474490  0.32826104
#> 86     S10     I09  5.0155412 3.018906  0.50621891 -0.1462518  1.63666846
#> 100    S10     I10  2.1022766 3.018906  0.50621891 -1.4821233  0.05927539