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    1.28418797 -0.896772204 -1.05711472 -0.94536832
#> 2    0.59865732 -0.856672782 -0.62006584 -1.13584848
#> 3    0.66322948 -0.873537287 -0.65837825 -1.00446263
#> 4   -0.17981303  0.364356467 -0.88200631 -1.73024328
#> 5    2.42943571 -0.717186307  0.49996133 -0.42026777
#> 6    0.32472389 -0.566624732  0.35010464  0.32468722
#> 7   -0.37928344 -1.184479504 -1.37181019 -0.52435851
#> 8    0.55782430 -0.679075294 -0.02320069 -0.29678589
#> 9   -0.60083693 -0.460273708 -0.99328117 -0.78444843
#> 10   0.54203292 -0.147266134 -0.81048833  0.06276401
#> 11   0.12425119 -1.351414527 -2.66065176 -0.95854098
#> 12   0.84275776 -1.265815280 -1.00651137  1.35683703
#> 13  -0.02156442 -1.443984815 -1.71704717 -1.58620646
#> 14  -0.94883804 -1.557843345 -1.39506490 -2.03086532
#> 15   0.02976575 -0.990231586  1.40651705  0.61024416
#> 16   0.49547879 -0.833884184 -1.03426726 -0.86308587
#> 17   1.88656425  0.304495086 -0.42491646  0.71903284
#> 18  -0.07170397 -1.530065008 -0.36997705 -0.93166031
#> 19  -0.13471209 -2.297740562 -0.86766344 -0.81487368
#> 20  -0.58669397 -1.844194075 -1.02937285 -1.72321245
#> 21  -1.67366563 -0.779186336 -3.32468125 -1.14401505
#> 22  -0.97405730 -2.144417092 -2.12628559 -1.04066855
#> 23   1.16460266 -0.643100573  1.03362317  0.35747781
#> 24   0.20422105 -0.949750709 -0.59790198 -0.97247911
#> 25  -0.74385283 -0.560218608  0.68426648 -0.80796721
#> 26   2.77584201  0.791256282 -1.12097790  0.65454513
#> 27   0.58245069 -0.262060240 -1.15636500 -1.36320182
#> 28   0.24361884 -1.218511104 -0.12132492 -0.24399813
#> 29   0.48328025 -0.396757748  0.68965528 -0.43705964
#> 30   0.05996359  0.028153443 -1.35586400 -0.47045456
#> 31   1.82174074 -0.806240922  1.46642645 -0.20908694
#> 32   0.70572728  1.020860483 -0.14057880 -1.04657372
#> 33  -0.56267182  0.523268115  0.46312879 -0.54553594
#> 34   1.78121113 -1.094811052 -0.13392738  0.76467795
#> 35   2.15231942  0.634433428  0.26749275 -0.46768424
#> 36   1.22975592  0.349642366  2.56132121 -0.63271983
#> 37   2.31081379 -0.915590740 -1.94903813 -0.14148807
#> 38  -0.37937904  0.778388013 -0.19317508 -1.25092918
#> 39  -0.59958448  0.362434694 -0.03975314 -1.04647730
#> 40   2.02768556  0.645393873 -0.20666962 -0.32272418
#> 41  -0.31835461  0.207793224  0.59519010  0.02213162
#> 42   1.10161445  0.273861705 -0.66343222  0.53622685
#> 43  -0.90503264 -0.871664866 -0.67486007 -0.63704391
#> 44   1.31251381  1.083433179  0.20307864  0.69144016
#> 45  -0.56672529 -2.868036283 -2.98383250 -1.34536891
#> 46  -2.11079394 -3.143866181 -2.76951667 -2.01914435
#> 47   1.34788385  2.009882734  0.73775177  0.44494631
#> 48  -1.23890972 -0.421620513 -0.89429128 -0.81427853
#> 49   0.93820490 -0.810485202 -1.02775366  0.92883391
#> 50  -0.08491062 -0.346483585 -0.08616497 -1.48433900
#> 51   1.66618642  1.196910875 -0.48312575  1.41927921
#> 52  -1.37859418 -2.860463745 -2.52624324 -1.19599637
#> 53   1.91521131  0.629205658 -0.92623453  0.06860749
#> 54   0.97907757  0.642386664 -0.40284999 -0.24128148
#> 55   0.90496824 -0.120403170  1.02608152  0.88634915
#> 56   0.68956295  0.725397586 -0.67494824  1.61501320
#> 57  -0.70873165 -0.896043305  0.86077607 -2.38943647
#> 58  -0.40891875 -0.571339395 -1.83818039 -0.15522748
#> 59   1.32290666 -0.313158694 -1.05916489 -0.41558368
#> 60   0.18377312 -2.568011415 -0.55491480 -1.52389549
#> 61  -1.23363293 -1.856311396 -1.75310892 -1.97111713
#> 62   0.52806846  0.202597278 -0.14824267 -0.38776931
#> 63   1.19015522 -1.164204312  0.15580117 -0.79517586
#> 64   0.07729300 -0.693387718 -0.39606714 -1.67933907
#> 65   1.65880112 -0.359787707  0.48338043 -0.75010300
#> 66   1.24886975  1.567334879  0.34552044 -0.18717023
#> 67   0.70444784  0.469493622  0.41889017 -0.01608539
#> 68  -0.10176294  0.519476274  0.10759790  0.53803607
#> 69   1.15431466 -2.184708931 -0.89805141 -0.61204695
#> 70   0.13971650 -1.814020684  0.65790929 -0.66791993
#> 71   1.56247214 -0.436240750  1.23714901  0.61415420
#> 72   2.02646921  0.381337694 -0.64498930  0.09716317
#> 73   1.66093805  0.068424720  1.29988502 -0.82439648
#> 74   0.16406980 -1.019734838 -0.95390601  0.03328547
#> 75   2.52986207  1.208178113  0.79004808  1.04552151
#> 76   0.37259036 -0.023516012  0.69659107 -0.75372873
#> 77  -0.55643360 -2.277921737 -1.65769407 -2.03300780
#> 78   0.89419716  0.645638873  0.07086938  0.10015633
#> 79  -0.94243125  1.031220993  2.10211899  0.96038785
#> 80   0.27545212 -0.701977642 -1.44685073 -0.13028936
#> 81  -1.31264768 -0.916456065 -1.30124711 -1.66637276
#> 82   1.18791707  2.265388065  1.98254043  0.49087118
#> 83   0.42852002  0.470506535  0.66584722  1.00840117
#> 84   1.47006122  0.047119386 -0.21663204  0.14121423
#> 85   1.26456450  0.048985103  0.76022646  0.82281287
#> 86   1.17355070  0.061084544 -0.36278769  1.03012137
#> 87  -0.38235179 -0.531498685 -0.17756311 -2.23207029
#> 88   0.66271124 -0.267077230 -1.18401654  0.29200087
#> 89  -0.33603234 -2.021233675 -1.46699450 -1.36100594
#> 90   1.03641392  0.556131323 -0.22567656 -0.44938340
#> 91  -0.21715314 -1.215333005 -1.53039149 -2.09242957
#> 92   2.48493102 -0.431097331  1.67747648  1.72127067
#> 93  -0.72644261 -2.653636510 -1.21255876 -1.27886612
#> 94   1.11066684  0.657073969 -0.63448848 -1.01021476
#> 95   0.78973706  0.007709657 -1.05480218  1.11351087
#> 96   0.18965931 -0.715569353 -0.60647560 -0.98647920
#> 97  -0.70332099 -0.578942497 -0.78447014  0.10228607
#> 98   0.23917113  0.344323732 -1.13300319  0.40453889
#> 99   1.77368415 -0.344474840 -1.15778851 -0.18391161
#> 100 -1.04301491 -1.383488765 -0.55977904 -1.60522376