Skip to contents

Simulate a dataset coming from a multivariate non-normal distribution specifying the vector of means, variance-covariance matrix, vector of skewnesses and kurtoses. The function use the semTools::mvrnonnorm() function.

Usage

sim_data(n, d, Sigma, skew = NULL, kurt = NULL)

Arguments

n

number of observations

d

the effect size (i.e., the vector of means of the multivariate distribution). If d is a vector of length 1, the value is recycled creating a vector of length nrow(Sigma), otherwise d need to be a vector of length Sigma. The function randomize the sign of d for each dimension.

Sigma

the variance-covariance matrix

skew

vector of skewnesses

kurt

vector of kurtoses

Value

a dataframe with simulated data

Examples

Sigma <- gen_sigma(4, 0.5)
sim_data(100, 0.5, Sigma)
#>                X1          X2           X3          X4
#> 1    0.6945013487 -0.12507322 -0.084744602  0.10309742
#> 2   -0.3828898844 -1.33385831 -0.437097779 -1.05315210
#> 3    1.0814923393 -0.38645371  0.724804412 -0.25185627
#> 4    1.6918001107  1.44675138  0.015250647  0.72239016
#> 5   -0.6021093300 -0.52978537 -0.073011332  0.36964183
#> 6    2.3725579783  1.88375320  0.166739515  1.05974036
#> 7    0.6352734344 -1.55537678 -0.497075108 -0.64424079
#> 8    0.0765336613 -0.50956835 -1.489388378 -1.24046458
#> 9    0.2222922081 -1.27343174 -1.776426002 -2.20889130
#> 10   0.4036463962 -0.53582695 -0.460563771 -1.30910749
#> 11   0.0235205467 -1.35395404 -0.404203246 -1.88127563
#> 12   2.6389529007  3.04609195 -0.035526875  1.62965450
#> 13   0.1746648906 -0.38828644 -1.810368397  0.85932690
#> 14  -0.3496375787 -1.46633367 -2.059883946 -2.18272017
#> 15   1.1746514965  0.37783645 -0.120640268  0.84872407
#> 16   2.3386021094  0.09213165  0.210431034  0.70816643
#> 17  -0.1426667935 -1.90981007 -1.849471973 -1.86632403
#> 18   0.9871465422 -0.06901940 -1.220952635 -1.16570157
#> 19  -0.5134629678 -0.79413692 -2.633165376 -1.68317549
#> 20   2.2471764995 -0.36881181 -0.945738607  0.10907292
#> 21   1.8271205330 -1.73339924 -1.391375192 -1.30985417
#> 22  -0.7322096130 -1.91084173 -0.781096154 -1.35694146
#> 23   1.8234974630 -0.36337624  1.033782893 -1.36466918
#> 24   2.0405048281 -0.03730409 -0.311523685  0.32763548
#> 25   0.8049850974 -0.58166721 -0.706354370  0.40211750
#> 26   2.0316737582  0.76383771  0.940526026  0.14216470
#> 27   2.5109493750 -0.24900665 -0.098419798  0.06019178
#> 28  -0.5469557943 -1.19279843 -0.298797799 -0.74141414
#> 29   1.1868961896 -0.46157676 -1.570637653 -0.19332706
#> 30   1.3414329085 -0.21483929  0.067578346 -0.12916267
#> 31  -0.6321191613 -1.28201022 -1.222773943 -1.11636645
#> 32  -1.3565659089  0.34043948 -0.329049094 -0.93247651
#> 33  -0.0739959337 -1.14830977 -0.236060691 -0.97084941
#> 34  -1.5938550306 -0.55425783 -0.208465510 -1.47698439
#> 35   3.3326545740 -0.31135888 -0.851220665  1.12513216
#> 36  -1.4514998175 -1.41982235 -2.634283750 -2.08719254
#> 37   1.5194212236 -0.48521273 -0.871573595 -1.81464032
#> 38   0.7955797805 -0.82517414 -0.554699811 -0.69957908
#> 39   1.7141529954  0.08550179 -0.592489328 -0.91131374
#> 40  -0.6028791866 -1.63904851 -0.328433489 -0.30814331
#> 41   0.0426143968 -1.11137189 -0.064904272 -0.65819826
#> 42   1.5626350472 -0.31483806 -0.670385961 -1.67346234
#> 43   2.1973948521  0.08112143  0.350290078  1.32981005
#> 44   1.0874288250 -0.40690423  0.242121039 -0.72579450
#> 45   1.0304463169 -0.63573224 -3.675435832 -1.16113882
#> 46  -0.7467360186 -2.59947055 -2.901800479 -1.47273367
#> 47   0.1577528349 -0.74458000 -1.097583482 -0.74858548
#> 48   0.8433927801 -0.24763319  0.094151410  0.27745117
#> 49   0.4860107778 -0.04043503 -0.583877141 -0.44911138
#> 50  -1.0712808781 -1.95680712 -0.173620197 -2.00829701
#> 51   0.6117463933 -0.89080767 -0.875597139 -1.33425481
#> 52  -0.4202290992 -0.98212668 -0.275510522 -1.01075466
#> 53   0.7088327391  0.36067509  1.246270243  2.07233548
#> 54   0.6308407150 -0.98519896 -1.268273509 -0.64532716
#> 55   1.6439492959 -0.41445733 -0.047066684 -0.62792205
#> 56   2.6806661984  1.53050504  0.351653371  0.46957693
#> 57  -0.9922336903  0.29153121 -0.902449050 -0.87276958
#> 58  -0.6267149154 -0.29657039 -2.175812725 -1.86602639
#> 59  -0.5086647294 -0.22611732 -1.345196851 -3.42010589
#> 60   2.3075500545 -0.51226689 -0.723559111 -0.19881817
#> 61  -0.0730584876  0.25240599 -0.409340734 -0.04641462
#> 62   2.1384635866  0.96907329  0.296770974  0.53933260
#> 63   2.4565875697 -0.73256044  1.627982854  1.51465498
#> 64   1.4948420167  0.13734344 -0.070029189  1.82591255
#> 65  -2.7502125399 -0.66762629 -1.113797752 -2.27395564
#> 66   0.2819917953 -0.81644026 -1.454618977 -1.88678240
#> 67  -0.7334834322 -1.57806538 -1.625672324 -1.01901403
#> 68   0.7860044569 -1.50519955 -1.248404826 -0.28017693
#> 69  -1.6242814933 -0.70720785 -1.068569935 -2.37159330
#> 70   0.1246862674 -0.66229362 -1.611422018  0.12857581
#> 71   0.1348743553 -1.97438628 -0.833476519 -0.76034479
#> 72   0.5625864056  0.73758784 -1.744106672  0.68091112
#> 73   0.6059885607 -0.64074153 -0.970486489 -0.59168752
#> 74   0.4336926333 -0.85854219  1.128803673 -0.49943069
#> 75   1.3867562080  1.27492861  1.182395430 -0.24047656
#> 76   0.6206307740 -0.41840023 -0.472297964  1.08241693
#> 77  -0.3741465121 -1.84109392 -1.461288967 -1.76798722
#> 78   0.9948943629 -0.02595679  0.254957171 -1.38445334
#> 79   0.7397643275 -0.22499607 -2.212720228 -0.69469737
#> 80   0.6817924695 -1.28835009 -2.075360845 -1.47261322
#> 81   2.1802761259 -0.22080196 -1.108934274 -0.31258722
#> 82  -0.0754660812  0.23673963  0.494420279 -1.15667351
#> 83  -0.1039725472  0.13932645 -1.841062125  0.64734532
#> 84   1.1517957636 -1.58428846  0.048356516 -1.03213776
#> 85   0.6497327465  1.07530652  0.928773732  1.11924865
#> 86   0.3835280855 -0.22077156 -0.649123877  0.08415271
#> 87  -0.3122574432 -1.65566439  0.181432449 -0.42665560
#> 88  -0.3787563564 -0.50060978 -0.105970619 -1.53360622
#> 89   1.7216953117  1.07530005 -0.582713872  0.41168575
#> 90   0.3479108061 -0.15068006 -0.034302124 -1.72968807
#> 91   0.5066991449 -0.02604716 -1.136000904 -0.22452172
#> 92   0.2385452904  0.85743242  0.118084741  0.10804016
#> 93  -1.1508288846 -3.13442981 -3.212423992 -1.65126130
#> 94   0.3044866259 -1.15718126 -0.510446096 -0.71117261
#> 95   0.0005102654 -0.18961885 -1.034471287 -0.60184728
#> 96   1.1551238212  0.85624417 -0.175194448  0.16148067
#> 97  -0.3574050562 -1.20128482 -0.384752977 -0.69752017
#> 98  -0.2011727958  0.04307491  0.009287984 -2.35704743
#> 99  -1.1257306831  0.16656025 -0.840130286 -0.75096658
#> 100  0.2253539465  0.07123285 -0.093428224 -0.59897297