Skip to contents

Makes a basic cross-classified design with random intercepts for subjects and items. See vignette("sim_mixed", package = "faux") for examples and details.

Usage

sim_mixed_cc(
  sub_n = 100,
  item_n = 20,
  grand_i = 0,
  sub_sd = 1,
  item_sd = 1,
  error_sd = 1,
  empirical = FALSE,
  seed = NULL
)

Arguments

sub_n

the number of subjects

item_n

the number of items

grand_i

the grand intercept (overall mean)

sub_sd

the SD of subject random intercepts (or a sub_n-length named vector of random intercepts for each subject)

item_sd

the SD of item random intercepts (or an item_n-length named vector of random intercepts for each item)

error_sd

the SD of the error term

empirical

Should the returned data have these exact parameters? (versus be sampled from a population with these parameters)

seed

DEPRECATED use set.seed() instead before running this function

Value

a tbl

Examples


sim_mixed_cc(10, 10)
#>     sub_id item_id           y grand_i      sub_i      item_i          err
#> 1      S01     I01  1.57974438       0 -0.7456337  1.76558706  0.559791048
#> 15     S01     I02 -3.63731466       0 -0.7456337 -1.42856370 -1.463117233
#> 29     S01     I03 -0.57637869       0 -0.7456337 -0.54175033  0.711005372
#> 31     S01     I04  0.78621551       0 -0.7456337  1.78032478 -0.248475548
#> 44     S01     I05 -0.22859174       0 -0.7456337  0.84556791 -0.328525917
#> 58     S01     I06 -0.20098974       0 -0.7456337  0.01850309  0.526140901
#> 61     S01     I07  0.24599639       0 -0.7456337 -0.44045721  1.432087330
#> 73     S01     I08 -0.31239580       0 -0.7456337  0.83156539 -0.398327460
#> 87     S01     I09  0.10317953       0 -0.7456337  0.48819809  0.360615169
#> 91     S01     I10 -2.14429769       0 -0.7456337 -0.55534081 -0.843323145
#> 7      S02     I01 -1.33637851       0 -0.5524794  1.76558706 -2.549486129
#> 17     S02     I02 -3.08770354       0 -0.5524794 -1.42856370 -1.106660401
#> 30     S02     I03 -2.46580584       0 -0.5524794 -0.54175033 -1.371576075
#> 36     S02     I04  2.05372690       0 -0.5524794  1.78032478  0.825881557
#> 46     S02     I05  0.43688746       0 -0.5524794  0.84556791  0.143798998
#> 59     S02     I06 -1.40036228       0 -0.5524794  0.01850309 -0.866385930
#> 69     S02     I07 -2.76058935       0 -0.5524794 -0.44045721 -1.767652703
#> 75     S02     I08 -0.32851504       0 -0.5524794  0.83156539 -0.607600990
#> 88     S02     I09 -0.87165834       0 -0.5524794  0.48819809 -0.807376995
#> 98     S02     I10 -1.52905366       0 -0.5524794 -0.55534081 -0.421233410
#> 4      S03     I01  1.03139450       0 -1.9265406  1.76558706  1.192348001
#> 18     S03     I02 -3.67030874       0 -1.9265406 -1.42856370 -0.315204487
#> 23     S03     I03 -2.39355832       0 -1.9265406 -0.54175033  0.074732572
#> 33     S03     I04 -1.10884106       0 -1.9265406  1.78032478 -0.962625287
#> 47     S03     I05 -0.55528936       0 -1.9265406  0.84556791  0.525683300
#> 60     S03     I06 -1.87364421       0 -1.9265406  0.01850309  0.034393259
#> 62     S03     I07 -1.64859007       0 -1.9265406 -0.44045721  0.718407700
#> 76     S03     I08 -1.54718507       0 -1.9265406  0.83156539 -0.452209901
#> 89     S03     I09 -3.01636990       0 -1.9265406  0.48819809 -1.578027426
#> 95     S03     I10 -2.37902512       0 -1.9265406 -0.55534081  0.102856249
#> 5      S04     I01  1.98367324       0 -1.1670320  1.76558706  1.385118184
#> 19     S04     I02 -3.26397852       0 -1.1670320 -1.42856370 -0.668382821
#> 21     S04     I03 -2.07170177       0 -1.1670320 -0.54175033 -0.362919441
#> 34     S04     I04  2.91948762       0 -1.1670320  1.78032478  2.306194836
#> 48     S04     I05 -1.96813840       0 -1.1670320  0.84556791 -1.646674304
#> 51     S04     I06 -1.08667009       0 -1.1670320  0.01850309  0.061858816
#> 63     S04     I07 -3.66397545       0 -1.1670320 -0.44045721 -2.056486239
#> 77     S04     I08 -1.02020296       0 -1.1670320  0.83156539 -0.684736354
#> 90     S04     I09  0.27854257       0 -1.1670320  0.48819809  0.957376476
#> 92     S04     I10 -0.52430380       0 -1.1670320 -0.55534081  1.198069014
#> 2      S05     I01  2.54274582       0  0.3917803  1.76558706  0.385378425
#> 16     S05     I02 -2.44473118       0  0.3917803 -1.42856370 -1.407947813
#> 22     S05     I03 -1.14506575       0  0.3917803 -0.54175033 -0.995095758
#> 35     S05     I04  3.76643586       0  0.3917803  1.78032478  1.594330745
#> 45     S05     I05  0.76241433       0  0.3917803  0.84556791 -0.474933909
#> 52     S05     I06  0.59684661       0  0.3917803  0.01850309  0.186563191
#> 64     S05     I07 -0.09645028       0  0.3917803 -0.44045721 -0.047773404
#> 74     S05     I08  1.22595509       0  0.3917803  0.83156539  0.002609366
#> 81     S05     I09  0.02345443       0  0.3917803  0.48819809 -0.856523991
#> 93     S05     I10  0.11659417       0  0.3917803 -0.55534081  0.280154650
#> 8      S06     I01 -0.05108336       0 -2.3417908  1.76558706  0.525120408
#> 20     S06     I02 -4.23773066       0 -2.3417908 -1.42856370 -0.467376131
#> 27     S06     I03 -2.80608003       0 -2.3417908 -0.54175033  0.077461124
#> 37     S06     I04 -2.53895896       0 -2.3417908  1.78032478 -1.977492914
#> 49     S06     I05 -1.30687950       0 -2.3417908  0.84556791  0.189343422
#> 56     S06     I06 -1.41676665       0 -2.3417908  0.01850309  0.906521093
#> 66     S06     I07 -1.94218409       0 -2.3417908 -0.44045721  0.840063954
#> 79     S06     I08 -1.51930957       0 -2.3417908  0.83156539 -0.009084133
#> 85     S06     I09 -1.57237235       0 -2.3417908  0.48819809  0.281220388
#> 99     S06     I10 -3.94825786       0 -2.3417908 -0.55534081 -1.051126212
#> 9      S07     I01  0.57896625       0 -0.6642951  1.76558706 -0.522325709
#> 11     S07     I02 -2.35159857       0 -0.6642951 -1.42856370 -0.258739780
#> 24     S07     I03 -1.43785279       0 -0.6642951 -0.54175033 -0.231807365
#> 38     S07     I04  1.51711352       0 -0.6642951  1.78032478  0.401083837
#> 50     S07     I05  0.62356336       0 -0.6642951  0.84556791  0.442290556
#> 53     S07     I06 -0.55633148       0 -0.6642951  0.01850309  0.089460528
#> 67     S07     I07 -1.39688450       0 -0.6642951 -0.44045721 -0.292132197
#> 80     S07     I08 -1.95481238       0 -0.6642951  0.83156539 -2.122082674
#> 82     S07     I09  1.81665665       0 -0.6642951  0.48819809  1.992753657
#> 96     S07     I10 -0.48763652       0 -0.6642951 -0.55534081  0.731999392
#> 6      S08     I01  3.52376285       0  0.8168627  1.76558706  0.941313066
#> 12     S08     I02 -0.22417343       0  0.8168627 -1.42856370  0.387527537
#> 25     S08     I03 -0.39570890       0  0.8168627 -0.54175033 -0.670821303
#> 39     S08     I04  4.06836623       0  0.8168627  1.78032478  1.471178721
#> 41     S08     I05  1.80568369       0  0.8168627  0.84556791  0.143253063
#> 54     S08     I06  0.64959247       0  0.8168627  0.01850309 -0.185773343
#> 68     S08     I07 -0.23144444       0  0.8168627 -0.44045721 -0.607849959
#> 78     S08     I08  2.93178959       0  0.8168627  0.83156539  1.283361472
#> 83     S08     I09  1.48184930       0  0.8168627  0.48819809  0.176788484
#> 97     S08     I10  0.31922434       0  0.8168627 -0.55534081  0.057702425
#> 3      S09     I01 -0.61745978       0 -2.9608527  1.76558706  0.577805835
#> 13     S09     I02 -3.59092957       0 -2.9608527 -1.42856370  0.798486797
#> 26     S09     I03 -3.77031840       0 -2.9608527 -0.54175033 -0.267715402
#> 32     S09     I04 -0.47516057       0 -2.9608527  1.78032478  0.705367314
#> 42     S09     I05 -1.87373766       0 -2.9608527  0.84556791  0.241547104
#> 55     S09     I06 -3.08887161       0 -2.9608527  0.01850309 -0.146522032
#> 65     S09     I07 -2.77280396       0 -2.9608527 -0.44045721  0.628505926
#> 71     S09     I08 -3.63058442       0 -2.9608527  0.83156539 -1.501297135
#> 84     S09     I09 -0.85762574       0 -2.9608527  0.48819809  1.615028842
#> 94     S09     I10 -4.29781441       0 -2.9608527 -0.55534081 -0.781620924
#> 10     S10     I01  0.58749890       0 -1.0071052  1.76558706 -0.170982974
#> 14     S10     I02 -3.22607119       0 -1.0071052 -1.42856370 -0.790402310
#> 28     S10     I03 -2.16716958       0 -1.0071052 -0.54175033 -0.618314064
#> 40     S10     I04  0.97981417       0 -1.0071052  1.78032478  0.206594576
#> 43     S10     I05  1.82857599       0 -1.0071052  0.84556791  1.990113266
#> 57     S10     I06 -0.92656624       0 -1.0071052  0.01850309  0.062035859
#> 70     S10     I07 -1.22363849       0 -1.0071052 -0.44045721  0.223923903
#> 72     S10     I08  0.59132249       0 -1.0071052  0.83156539  0.766862290
#> 86     S10     I09 -1.09856370       0 -1.0071052  0.48819809 -0.579656607
#> 100    S10     I10  0.20565131       0 -1.0071052 -0.55534081  1.768097309