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

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.539828264       0  1.4466654 -0.05547189 -0.851365200
#> 15     S01     I02  2.458954583       0  1.4466654  1.60304543 -0.590756195
#> 29     S01     I03  0.502405326       0  1.4466654  0.07045021 -1.014710231
#> 31     S01     I04 -0.722684591       0  1.4466654 -1.87230959 -0.297040353
#> 44     S01     I05  0.986449277       0  1.4466654  0.38762466 -0.847840735
#> 58     S01     I06  3.329230931       0  1.4466654  0.03769370  1.844871881
#> 61     S01     I07  2.044654168       0  1.4466654 -0.24743349  0.845422308
#> 73     S01     I08 -0.182433943       0  1.4466654 -0.32313149 -1.305967802
#> 87     S01     I09  0.384890033       0  1.4466654 -1.37277135  0.310996030
#> 91     S01     I10 -0.098701084       0  1.4466654 -0.66574635 -0.879620082
#> 7      S02     I01  0.913922778       0  1.5363287 -0.05547189 -0.566934085
#> 17     S02     I02  2.923221218       0  1.5363287  1.60304543 -0.216152959
#> 30     S02     I03  1.158060299       0  1.5363287  0.07045021 -0.448718658
#> 36     S02     I04  0.370398881       0  1.5363287 -1.87230959  0.706379720
#> 46     S02     I05  1.039710295       0  1.5363287  0.38762466 -0.884243116
#> 59     S02     I06  1.107979704       0  1.5363287  0.03769370 -0.466042745
#> 69     S02     I07  1.348072775       0  1.5363287 -0.24743349  0.059177516
#> 75     S02     I08  1.548987078       0  1.5363287 -0.32313149  0.335789820
#> 88     S02     I09  1.200480759       0  1.5363287 -1.37277135  1.036923358
#> 98     S02     I10 -0.444342719       0  1.5363287 -0.66574635 -1.314925117
#> 4      S03     I01  1.096851906       0  1.1174560 -0.05547189  0.034867771
#> 18     S03     I02  3.916220065       0  1.1174560  1.60304543  1.195718616
#> 23     S03     I03  0.601589336       0  1.1174560  0.07045021 -0.586316893
#> 33     S03     I04 -0.005270974       0  1.1174560 -1.87230959  0.749582593
#> 47     S03     I05  2.036312281       0  1.1174560  0.38762466  0.531231598
#> 60     S03     I06  1.116454351       0  1.1174560  0.03769370 -0.038695371
#> 62     S03     I07  1.570131557       0  1.1174560 -0.24743349  0.700109026
#> 76     S03     I08  2.457661754       0  1.1174560 -0.32313149  1.663337223
#> 89     S03     I09 -1.523544121       0  1.1174560 -1.37277135 -1.268228795
#> 95     S03     I10 -1.058033119       0  1.1174560 -0.66574635 -1.509742789
#> 5      S04     I01  1.222182960       0  0.6907696 -0.05547189  0.586885207
#> 19     S04     I02  1.926986983       0  0.6907696  1.60304543 -0.366828084
#> 21     S04     I03  1.321559774       0  0.6907696  0.07045021  0.560339927
#> 34     S04     I04 -2.862660700       0  0.6907696 -1.87230959 -1.681120750
#> 48     S04     I05  2.824309775       0  0.6907696  0.38762466  1.745915474
#> 51     S04     I06  0.162542470       0  0.6907696  0.03769370 -0.565920869
#> 63     S04     I07 -1.537915089       0  0.6907696 -0.24743349 -1.981251238
#> 77     S04     I08  1.442280393       0  0.6907696 -0.32313149  1.074642245
#> 90     S04     I09  1.097917359       0  0.6907696 -1.37277135  1.779919068
#> 92     S04     I10  1.366424593       0  0.6907696 -0.66574635  1.341401306
#> 2      S05     I01  0.464900041       0  0.8463048 -0.05547189 -0.325932849
#> 16     S05     I02  3.659557877       0  0.8463048  1.60304543  1.210207673
#> 22     S05     I03  2.314319161       0  0.8463048  0.07045021  1.397564178
#> 35     S05     I04 -2.260642166       0  0.8463048 -1.87230959 -1.234637354
#> 45     S05     I05  1.980036410       0  0.8463048  0.38762466  0.746106972
#> 52     S05     I06  0.147804282       0  0.8463048  0.03769370 -0.736194195
#> 64     S05     I07 -0.154331374       0  0.8463048 -0.24743349 -0.753202660
#> 74     S05     I08  0.572594440       0  0.8463048 -0.32313149  0.049421155
#> 81     S05     I09 -1.622478976       0  0.8463048 -1.37277135 -1.096012405
#> 93     S05     I10 -1.014837507       0  0.8463048 -0.66574635 -1.195395932
#> 8      S06     I01 -1.215109529       0 -1.0629866 -0.05547189 -0.096651065
#> 20     S06     I02  1.331529995       0 -1.0629866  1.60304543  0.791471146
#> 27     S06     I03 -0.161944835       0 -1.0629866  0.07045021  0.830591536
#> 37     S06     I04 -3.317529775       0 -1.0629866 -1.87230959 -0.382233608
#> 49     S06     I05 -1.523124280       0 -1.0629866  0.38762466 -0.847762363
#> 56     S06     I06 -0.290519155       0 -1.0629866  0.03769370  0.734773723
#> 66     S06     I07 -3.001286036       0 -1.0629866 -0.24743349 -1.690865967
#> 79     S06     I08 -0.942607888       0 -1.0629866 -0.32313149  0.443510182
#> 85     S06     I09 -1.734377032       0 -1.0629866 -1.37277135  0.701380895
#> 99     S06     I10 -3.028493795       0 -1.0629866 -0.66574635 -1.299760865
#> 9      S07     I01 -2.708236570       0 -1.3790310 -0.05547189 -1.273733637
#> 11     S07     I02  0.204532333       0 -1.3790310  1.60304543 -0.019482048
#> 24     S07     I03 -1.946900401       0 -1.3790310  0.07045021 -0.638319561
#> 38     S07     I04 -2.784831865       0 -1.3790310 -1.87230959  0.466508771
#> 50     S07     I05 -3.155804146       0 -1.3790310  0.38762466 -2.164397760
#> 53     S07     I06  0.846345027       0 -1.3790310  0.03769370  2.187682374
#> 67     S07     I07 -1.355210766       0 -1.3790310 -0.24743349  0.271253772
#> 80     S07     I08 -0.416822782       0 -1.3790310 -0.32313149  1.285339757
#> 82     S07     I09 -1.491604729       0 -1.3790310 -1.37277135  1.260197665
#> 96     S07     I10 -1.638103573       0 -1.3790310 -0.66574635  0.406673825
#> 6      S08     I01  2.069487408       0  0.5959609 -0.05547189  1.528998345
#> 12     S08     I02  2.609873101       0  0.5959609  1.60304543  0.410866724
#> 25     S08     I03  0.269721248       0  0.5959609  0.07045021 -0.396689908
#> 39     S08     I04 -2.439487260       0  0.5959609 -1.87230959 -1.163138620
#> 41     S08     I05 -1.904078036       0  0.5959609  0.38762466 -2.887663647
#> 54     S08     I06  1.348249020       0  0.5959609  0.03769370  0.714594371
#> 68     S08     I07 -0.416063977       0  0.5959609 -0.24743349 -0.764591436
#> 78     S08     I08  1.161888240       0  0.5959609 -0.32313149  0.889058782
#> 83     S08     I09 -2.320525450       0  0.5959609 -1.37277135 -1.543715051
#> 97     S08     I10 -0.155933490       0  0.5959609 -0.66574635 -0.086148088
#> 3      S09     I01  0.693378590       0 -0.9259751 -0.05547189  1.674825554
#> 13     S09     I02  1.078655779       0 -0.9259751  1.60304543  0.401585429
#> 26     S09     I03 -1.487040692       0 -0.9259751  0.07045021 -0.631515822
#> 32     S09     I04 -2.807753014       0 -0.9259751 -1.87230959 -0.009468347
#> 42     S09     I05  0.616025664       0 -0.9259751  0.38762466  1.154376080
#> 55     S09     I06 -0.423517401       0 -0.9259751  0.03769370  0.464763977
#> 65     S09     I07 -0.800553812       0 -0.9259751 -0.24743349  0.372854757
#> 71     S09     I08 -1.324253640       0 -0.9259751 -0.32313149 -0.075147071
#> 84     S09     I09 -2.807453486       0 -0.9259751 -1.37277135 -0.508707060
#> 94     S09     I10 -2.517258583       0 -0.9259751 -0.66574635 -0.925537153
#> 10     S10     I01 -0.011054028       0  0.5909047 -0.05547189 -0.546486891
#> 14     S10     I02  2.590772875       0  0.5909047  1.60304543  0.396822697
#> 28     S10     I03  0.292023512       0  0.5909047  0.07045021 -0.369331445
#> 40     S10     I04 -0.564232984       0  0.5909047 -1.87230959  0.717171855
#> 43     S10     I05  2.675350158       0  0.5909047  0.38762466  1.696820747
#> 57     S10     I06 -0.716730186       0  0.5909047  0.03769370 -1.345328635
#> 70     S10     I07 -0.604798022       0  0.5909047 -0.24743349 -0.948269281
#> 72     S10     I08  1.841309978       0  0.5909047 -0.32313149  1.573536720
#> 86     S10     I09  0.383531186       0  0.5909047 -1.37277135  1.165397785
#> 100    S10     I10  1.146449733       0  0.5909047 -0.66574635  1.221291335