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  0.11138858       0 -0.82934037  0.5061139  0.43461501
#> 15     S01     I02 -0.81307920       0 -0.82934037 -0.6422030  0.65846421
#> 29     S01     I03 -1.66215884       0 -0.82934037 -1.1919609  0.35914242
#> 31     S01     I04 -1.45637848       0 -0.82934037  0.4521354 -1.07917352
#> 44     S01     I05  1.57035956       0 -0.82934037  0.6939601  1.70573986
#> 58     S01     I06  0.24612839       0 -0.82934037 -0.4971279  1.57259663
#> 61     S01     I07 -0.83501241       0 -0.82934037  0.3780080 -0.38368010
#> 73     S01     I08 -1.28364991       0 -0.82934037  0.8327482 -1.28705774
#> 87     S01     I09 -1.00667299       0 -0.82934037  0.3245808 -0.50191343
#> 91     S01     I10 -2.41694772       0 -0.82934037 -0.6686266 -0.91898072
#> 7      S02     I01  0.38242003       0 -0.06023448  0.5061139 -0.06345943
#> 17     S02     I02 -1.00337281       0 -0.06023448 -0.6422030 -0.30093528
#> 30     S02     I03  0.64387703       0 -0.06023448 -1.1919609  1.89607241
#> 36     S02     I04 -0.04437200       0 -0.06023448  0.4521354 -0.43627293
#> 46     S02     I05  0.93350809       0 -0.06023448  0.6939601  0.29978251
#> 59     S02     I06  0.21732575       0 -0.06023448 -0.4971279  0.77468810
#> 69     S02     I07  2.02137827       0 -0.06023448  0.3780080  1.70360470
#> 75     S02     I08 -0.66778463       0 -0.06023448  0.8327482 -1.44029835
#> 88     S02     I09 -0.60798030       0 -0.06023448  0.3245808 -0.87232662
#> 98     S02     I10 -0.49725439       0 -0.06023448 -0.6686266  0.23160672
#> 4      S03     I01  2.49090018       0  1.34776012  0.5061139  0.63702612
#> 18     S03     I02  0.15831488       0  1.34776012 -0.6422030 -0.54724220
#> 23     S03     I03  0.40971307       0  1.34776012 -1.1919609  0.25391385
#> 33     S03     I04  1.05150517       0  1.34776012  0.4521354 -0.74839036
#> 47     S03     I05  3.11838800       0  1.34776012  0.6939601  1.07666781
#> 60     S03     I06  0.69103818       0  1.34776012 -0.4971279 -0.15959408
#> 62     S03     I07  2.67788323       0  1.34776012  0.3780080  0.95211506
#> 76     S03     I08  2.34414047       0  1.34776012  0.8327482  0.16363215
#> 89     S03     I09  2.30780323       0  1.34776012  0.3245808  0.63546231
#> 95     S03     I10  0.36930499       0  1.34776012 -0.6686266 -0.30982849
#> 5      S04     I01 -0.59715435       0 -0.78918445  0.5061139 -0.31408385
#> 19     S04     I02 -1.73718977       0 -0.78918445 -0.6422030 -0.30580228
#> 21     S04     I03 -2.94840448       0 -0.78918445 -1.1919609 -0.96725913
#> 34     S04     I04 -0.90078488       0 -0.78918445  0.4521354 -0.56373584
#> 48     S04     I05  0.04137551       0 -0.78918445  0.6939601  0.13659990
#> 51     S04     I06 -0.66987520       0 -0.78918445 -0.4971279  0.61643711
#> 63     S04     I07 -1.31699202       0 -0.78918445  0.3780080 -0.90581563
#> 77     S04     I08 -1.35974362       0 -0.78918445  0.8327482 -1.40330737
#> 90     S04     I09 -1.15253512       0 -0.78918445  0.3245808 -0.68793147
#> 92     S04     I10 -1.19224042       0 -0.78918445 -0.6686266  0.26557066
#> 2      S05     I01  0.41217672       0 -1.18833080  0.5061139  1.09439358
#> 16     S05     I02 -0.33439624       0 -1.18833080 -0.6422030  1.49613760
#> 22     S05     I03 -1.74597311       0 -1.18833080 -1.1919609  0.63431859
#> 35     S05     I04 -0.45096370       0 -1.18833080  0.4521354  0.28523169
#> 45     S05     I05  1.37559688       0 -1.18833080  0.6939601  1.86996761
#> 52     S05     I06 -1.73749243       0 -1.18833080 -0.4971279 -0.05203376
#> 64     S05     I07 -0.51364858       0 -1.18833080  0.3780080  0.29667416
#> 74     S05     I08 -1.75790240       0 -1.18833080  0.8327482 -1.40231980
#> 81     S05     I09 -2.19217044       0 -1.18833080  0.3245808 -1.32842044
#> 93     S05     I10 -0.15771656       0 -1.18833080 -0.6686266  1.69924088
#> 8      S06     I01  1.49336642       0  0.32257455  0.5061139  0.66467793
#> 20     S06     I02  0.52537690       0  0.32257455 -0.6422030  0.84500540
#> 27     S06     I03 -0.40365785       0  0.32257455 -1.1919609  0.46572851
#> 37     S06     I04 -0.32497178       0  0.32257455  0.4521354 -1.09968173
#> 49     S06     I05  0.74367159       0  0.32257455  0.6939601 -0.27286302
#> 56     S06     I06  0.36325946       0  0.32257455 -0.4971279  0.53781278
#> 66     S06     I07  0.62531139       0  0.32257455  0.3780080 -0.07527121
#> 79     S06     I08  0.01706845       0  0.32257455  0.8327482 -1.13825430
#> 85     S06     I09 -0.51735938       0  0.32257455  0.3245808 -1.16451473
#> 99     S06     I10 -0.74506277       0  0.32257455 -0.6686266 -0.39901069
#> 9      S07     I01  3.03083449       0  1.76121962  0.5061139  0.76350093
#> 11     S07     I02  0.25139416       0  1.76121962 -0.6422030 -0.86762241
#> 24     S07     I03 -0.47973858       0  1.76121962 -1.1919609 -1.04899730
#> 38     S07     I04  1.96185120       0  1.76121962  0.4521354 -0.25150382
#> 50     S07     I05  3.97965980       0  1.76121962  0.6939601  1.52448012
#> 53     S07     I06  1.53723118       0  1.76121962 -0.4971279  0.27313943
#> 67     S07     I07  0.88787363       0  1.76121962  0.3780080 -1.25135403
#> 80     S07     I08  2.91541459       0  1.76121962  0.8327482  0.32144678
#> 82     S07     I09  2.27017645       0  1.76121962  0.3245808  0.18437603
#> 96     S07     I10  1.15472060       0  1.76121962 -0.6686266  0.06212762
#> 6      S08     I01 -0.04392048       0 -1.01533990  0.5061139  0.46530549
#> 12     S08     I02 -1.58833128       0 -1.01533990 -0.6422030  0.06921167
#> 25     S08     I03 -2.01904268       0 -1.01533990 -1.1919609  0.18825812
#> 39     S08     I04 -0.19768427       0 -1.01533990  0.4521354  0.36552023
#> 41     S08     I05  0.81118587       0 -1.01533990  0.6939601  1.13256571
#> 54     S08     I06  0.28676473       0 -1.01533990 -0.4971279  1.79923250
#> 68     S08     I07  0.61764890       0 -1.01533990  0.3780080  1.25498075
#> 78     S08     I08  0.23708792       0 -1.01533990  0.8327482  0.41967963
#> 83     S08     I09 -1.95214982       0 -1.01533990  0.3245808 -1.26139072
#> 97     S08     I10 -1.43443099       0 -1.01533990 -0.6686266  0.24953555
#> 3      S09     I01 -0.38713573       0 -2.05044979  0.5061139  1.15720013
#> 13     S09     I02 -4.00771209       0 -2.05044979 -0.6422030 -1.31505926
#> 26     S09     I03 -4.21696298       0 -2.05044979 -1.1919609 -0.97455229
#> 32     S09     I04 -2.04476999       0 -2.05044979  0.4521354 -0.44645561
#> 42     S09     I05 -0.91695699       0 -2.05044979  0.6939601  0.43953273
#> 55     S09     I06 -3.03708015       0 -2.05044979 -0.4971279 -0.48950249
#> 65     S09     I07 -3.17478653       0 -2.05044979  0.3780080 -1.50234479
#> 71     S09     I08 -2.75573318       0 -2.05044979  0.8327482 -1.53803158
#> 84     S09     I09 -0.76157538       0 -2.05044979  0.3245808  0.96429361
#> 94     S09     I10 -3.19036334       0 -2.05044979 -0.6686266 -0.47128692
#> 10     S10     I01  1.74805343       0 -0.46470130  0.5061139  1.70664079
#> 14     S10     I02 -1.77162146       0 -0.46470130 -0.6422030 -0.66471711
#> 28     S10     I03 -2.83179482       0 -0.46470130 -1.1919609 -1.17513261
#> 40     S10     I04  0.94557174       0 -0.46470130  0.4521354  0.95813763
#> 43     S10     I05  0.44438112       0 -0.46470130  0.6939601  0.21512236
#> 57     S10     I06 -0.83565213       0 -0.46470130 -0.4971279  0.12617704
#> 70     S10     I07  0.61424683       0 -0.46470130  0.3780080  0.70094009
#> 72     S10     I08  0.13552063       0 -0.46470130  0.8327482 -0.23252626
#> 86     S10     I09 -1.62008039       0 -0.46470130  0.3245808 -1.47995988
#> 100    S10     I10 -0.54536553       0 -0.46470130 -0.6686266  0.58796241