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  1.36671812 3.018906 -0.03615728  0.2455884 -1.861618594
#> 15     S01     I02  2.05302907 3.018906 -0.03615728  0.0576317 -0.987350950
#> 29     S01     I03  2.64116589 3.018906 -0.03615728 -0.6737036  0.332121175
#> 31     S01     I04  1.31849207 3.018906 -0.03615728 -0.9261576 -0.738098660
#> 44     S01     I05  4.07409883 3.018906 -0.03615728  0.5108941  0.580456439
#> 58     S01     I06  3.79852217 3.018906 -0.03615728  0.3593468  0.456426991
#> 61     S01     I07  4.52015554 3.018906 -0.03615728  0.2997471  1.237660150
#> 73     S01     I08  5.04391017 3.018906 -0.03615728  0.9735029  1.087658893
#> 87     S01     I09  2.01853137 3.018906 -0.03615728 -0.7390532 -0.225163778
#> 91     S01     I10  0.08679706 3.018906 -0.03615728 -1.0108160 -1.885135289
#> 7      S02     I01  4.72061621 3.018906  0.34451792  0.2455884  1.111604291
#> 17     S02     I02  3.01298144 3.018906  0.34451792  0.0576317 -0.408073794
#> 30     S02     I03  3.06741569 3.018906  0.34451792 -0.6737036  0.377695770
#> 36     S02     I04  3.16342940 3.018906  0.34451792 -0.9261576  0.726163463
#> 46     S02     I05  2.46660630 3.018906  0.34451792  0.5108941 -1.407711292
#> 59     S02     I06  4.70977410 3.018906  0.34451792  0.3593468  0.987003715
#> 69     S02     I07  3.24251297 3.018906  0.34451792  0.2997471 -0.420657629
#> 75     S02     I08  4.60509504 3.018906  0.34451792  0.9735029  0.268168557
#> 88     S02     I09  0.77554295 3.018906  0.34451792 -0.7390532 -1.848827400
#> 98     S02     I10  0.21619075 3.018906  0.34451792 -1.0108160 -2.136416806
#> 4      S03     I01  1.03413185 3.018906 -1.43310124  0.2455884 -0.797260911
#> 18     S03     I02  2.11878450 3.018906 -1.43310124  0.0576317  0.475348432
#> 23     S03     I03  1.48418426 3.018906 -1.43310124 -0.6737036  0.572083507
#> 33     S03     I04 -0.45004110 3.018906 -1.43310124 -0.9261576 -1.109687874
#> 47     S03     I05  2.17473391 3.018906 -1.43310124  0.5108941  0.078035480
#> 60     S03     I06  3.47862888 3.018906 -1.43310124  0.3593468  1.533477664
#> 62     S03     I07  2.09137246 3.018906 -1.43310124  0.2997471  0.205821019
#> 76     S03     I08  3.57881213 3.018906 -1.43310124  0.9735029  1.019504806
#> 89     S03     I09  0.58058571 3.018906 -1.43310124 -0.7390532 -0.266165479
#> 95     S03     I10 -0.47819787 3.018906 -1.43310124 -1.0108160 -1.053186265
#> 5      S04     I01  2.71192351 3.018906  0.98588634  0.2455884 -1.538456824
#> 19     S04     I02  4.06767180 3.018906  0.98588634  0.0576317  0.005248153
#> 21     S04     I03  2.57121707 3.018906  0.98588634 -0.6737036 -0.759871264
#> 34     S04     I04  3.77686990 3.018906  0.98588634 -0.9261576  0.698235553
#> 48     S04     I05  3.44384866 3.018906  0.98588634  0.5108941 -1.071837347
#> 51     S04     I06  3.17874045 3.018906  0.98588634  0.3593468 -1.185398344
#> 63     S04     I07  3.63984487 3.018906  0.98588634  0.2997471 -0.664694143
#> 77     S04     I08  7.55034788 3.018906  0.98588634  0.9735029  2.572052982
#> 90     S04     I09  3.12757235 3.018906  0.98588634 -0.7390532 -0.138166420
#> 92     S04     I10  2.78825265 3.018906  0.98588634 -1.0108160 -0.205723315
#> 2      S05     I01  3.90066533 3.018906 -0.49365096  0.2455884  1.129822296
#> 16     S05     I02  3.78361265 3.018906 -0.49365096  0.0576317  1.200726302
#> 22     S05     I03  1.78996989 3.018906 -0.49365096 -0.6737036 -0.061581148
#> 35     S05     I04  2.03165549 3.018906 -0.49365096 -0.9261576  0.432558432
#> 45     S05     I05  4.34025330 3.018906 -0.49365096  0.5108941  1.304104584
#> 52     S05     I06  5.80795964 3.018906 -0.49365096  0.3593468  2.923358138
#> 64     S05     I07  4.12759260 3.018906 -0.49365096  0.2997471  1.302590884
#> 74     S05     I08  2.83424777 3.018906 -0.49365096  0.9735029 -0.664509827
#> 81     S05     I09  2.01778099 3.018906 -0.49365096 -0.7390532  0.231579514
#> 93     S05     I10  2.77839713 3.018906 -0.49365096 -1.0108160  1.263958461
#> 8      S06     I01  4.66576830 3.018906  1.15479354  0.2455884  0.246480759
#> 20     S06     I02  5.93342995 3.018906  1.15479354  0.0576317  1.702099093
#> 27     S06     I03  2.87120410 3.018906  1.15479354 -0.6737036 -0.628791436
#> 37     S06     I04  3.03996024 3.018906  1.15479354 -0.9261576 -0.207581319
#> 49     S06     I05  3.80286252 3.018906  1.15479354  0.5108941 -0.881730694
#> 56     S06     I06  3.40760298 3.018906  1.15479354  0.3593468 -1.125443020
#> 66     S06     I07  5.51060144 3.018906  1.15479354  0.2997471  1.037155222
#> 79     S06     I08  6.19913819 3.018906  1.15479354  0.9735029  1.051936084
#> 85     S06     I09  3.90891412 3.018906  1.15479354 -0.7390532  0.474268150
#> 99     S06     I10  1.23670230 3.018906  1.15479354 -1.0108160 -1.926180869
#> 9      S07     I01  2.85476558 3.018906 -0.36233666  0.2455884 -0.047391755
#> 11     S07     I02  2.95557667 3.018906 -0.36233666  0.0576317  0.241376017
#> 24     S07     I03  2.23535523 3.018906 -0.36233666 -0.6737036  0.252489894
#> 38     S07     I04  0.33857447 3.018906 -0.36233666 -0.9261576 -1.391836886
#> 50     S07     I05  2.58502765 3.018906 -0.36233666  0.5108941 -0.582435363
#> 53     S07     I06  2.99249145 3.018906 -0.36233666  0.3593468 -0.023424353
#> 67     S07     I07  3.39176159 3.018906 -0.36233666  0.2997471  0.435445567
#> 80     S07     I08  2.43881652 3.018906 -0.36233666  0.9735029 -1.191255380
#> 82     S07     I09  3.19992264 3.018906 -0.36233666 -0.7390532  1.282406863
#> 96     S07     I10 -1.09540154 3.018906 -0.36233666 -1.0108160 -2.741154514
#> 6      S08     I01  4.13625822 3.018906 -0.47011523  0.2455884  1.341879454
#> 12     S08     I02  3.41971908 3.018906 -0.47011523  0.0576317  0.813297000
#> 25     S08     I03  2.39692622 3.018906 -0.47011523 -0.6737036  0.521839453
#> 39     S08     I04  2.14486937 3.018906 -0.47011523 -0.9261576  0.522236592
#> 41     S08     I05  2.44222310 3.018906 -0.47011523  0.5108941 -0.617461342
#> 54     S08     I06  1.94036666 3.018906 -0.47011523  0.3593468 -0.967770567
#> 68     S08     I07  2.46543459 3.018906 -0.47011523  0.2997471 -0.383102854
#> 78     S08     I08  2.09239447 3.018906 -0.47011523  0.9735029 -1.429898858
#> 83     S08     I09  0.46398131 3.018906 -0.47011523 -0.7390532 -1.345755895
#> 97     S08     I10  1.04124547 3.018906 -0.47011523 -1.0108160 -0.496728933
#> 3      S09     I01  3.53568017 3.018906 -0.29395797  0.2455884  0.565144138
#> 13     S09     I02  1.22415245 3.018906 -0.29395797  0.0576317 -1.558426894
#> 26     S09     I03  1.17153289 3.018906 -0.29395797 -0.6737036 -0.879711134
#> 32     S09     I04  2.85587562 3.018906 -0.29395797 -0.9261576  1.057085580
#> 42     S09     I05  2.78328967 3.018906 -0.29395797  0.5108941 -0.452552036
#> 55     S09     I06  3.54540512 3.018906 -0.29395797  0.3593468  0.461110625
#> 65     S09     I07  4.72270316 3.018906 -0.29395797  0.2997471  1.698008453
#> 71     S09     I08  4.79846071 3.018906 -0.29395797  0.9735029  1.100010125
#> 84     S09     I09  1.49638866 3.018906 -0.29395797 -0.7390532 -0.489505805
#> 94     S09     I10  1.05385074 3.018906 -0.29395797 -1.0108160 -0.660280922
#> 10     S10     I01  3.25294872 3.018906 -0.17156410  0.2455884  0.160018818
#> 14     S10     I02  4.77675774 3.018906 -0.17156410  0.0576317  1.871784528
#> 28     S10     I03  0.61859812 3.018906 -0.17156410 -0.6737036 -1.555039779
#> 40     S10     I04  2.86625848 3.018906 -0.17156410 -0.9261576  0.945074569
#> 43     S10     I05  2.94318786 3.018906 -0.17156410  0.5108941 -0.415047716
#> 57     S10     I06  2.18426507 3.018906 -0.17156410  0.3593468 -1.022423290
#> 70     S10     I07  2.62541047 3.018906 -0.17156410  0.2997471 -0.521678104
#> 72     S10     I08  3.89885354 3.018906 -0.17156410  0.9735029  0.078009081
#> 86     S10     I09  1.16892044 3.018906 -0.17156410 -0.7390532 -0.939367892
#> 100    S10     I10  1.92046160 3.018906 -0.17156410 -1.0108160  0.083936067