The Rosenblatt transform takes data generated from a model and turns it into independent uniform variates, The inverse Rosenblatt transform computes conditional quantiles and can be used simulate from a stochastic model, see Details.

rosenblatt(x, model, cores = 1)

inverse_rosenblatt(u, model, cores = 1)

Arguments

x

matrix of evaluation points; must be in \((0, 1)^d\) for copula models.

model

a model object; classes currently supported are bicop_dist(), vinecop_dist(), and vine_dist().

cores

if >1, computation is parallelized over cores batches (rows of u).

u

matrix of evaluation points; must be in \((0, 1)^d\).

Details

The Rosenblatt transform (Rosenblatt, 1952) \(U = T(V)\) of a random vector \(V = (V_1,\ldots,V_d) ~ F\) is defined as $$ U_1= F(V_1), U_{2} = F(V_{2}|V_1), \ldots, U_d =F(V_d|V_1,\ldots,V_{d-1}), $$ where \(F(v_k|v_1,\ldots,v_{k-1})\) is the conditional distribution of \(V_k\) given \(V_1 \ldots, V_{k-1}, k = 2,\ldots,d\). The vector \(U = (U_1, \dots, U_d)\) then contains independent standard uniform variables. The inverse operation $$ V_1 = F^{-1}(U_1), V_{2} = F^{-1}(U_2|U_1), \ldots, V_d =F^{-1}(U_d|U_1,\ldots,U_{d-1}), $$ can be used to simulate from a distribution. For any copula \(F\), if \(U\) is a vector of independent random variables, \(V = T^{-1}(U)\) has distribution \(F\).

The formulas above assume a vine copula model with order \(d, \dots, 1\). More generally, rosenblatt() returns the variables $$ U_{M[d + 1- j, j]}= F(V_{M[d + 1- j, j]} | V_{M[d - j, j - 1]}, \dots, V_{M[1, 1]}), $$ where \(M\) is the structure matrix. Similarly, inverse_rosenblatt() returns $$ V_{M[d + 1- j, j]}= F^{-1}(U_{M[d + 1- j, j]} | U_{M[d - j, j - 1]}, \dots, U_{M[1, 1]}). $$

Examples

# simulate data with some dependence
x <- replicate(3, rnorm(200))
x[, 2:3] <- x[, 2:3] + x[, 1]
pairs(x)


# estimate a vine distribution model
fit <- vine(x, copula_controls = list(family_set = "par"))

# transform into independent uniforms
u <- rosenblatt(x, fit)
pairs(u)


# inversion
pairs(inverse_rosenblatt(u, fit))


# works similarly for vinecop models
vc <- fit$copula
rosenblatt(pseudo_obs(x), vc)
#>               [,1]       [,2]        [,3]
#>   [1,] 0.069354120 0.21591692 0.537313433
#>   [2,] 0.551465949 0.08278169 0.935323383
#>   [3,] 0.165226624 0.53963734 0.223880597
#>   [4,] 0.212697693 0.60094715 0.810945274
#>   [5,] 0.254562172 0.40662162 0.447761194
#>   [6,] 0.993541359 0.97302074 0.184079602
#>   [7,] 0.926266091 0.58386790 0.661691542
#>   [8,] 0.001470768 0.65554073 0.731343284
#>   [9,] 0.255619289 0.46566402 0.019900498
#>  [10,] 0.615436146 0.23198225 0.766169154
#>  [11,] 0.825702630 0.51480246 0.069651741
#>  [12,] 0.336656131 0.49596500 0.786069652
#>  [13,] 0.728671303 0.94481286 0.194029851
#>  [14,] 0.825165304 0.66394671 0.174129353
#>  [15,] 0.173783948 0.93733828 0.925373134
#>  [16,] 0.206981053 0.44433956 0.278606965
#>  [17,] 0.980883439 0.14630744 0.940298507
#>  [18,] 0.546481205 0.65263693 0.686567164
#>  [19,] 0.838874883 0.44064114 0.865671642
#>  [20,] 0.536213400 0.27266784 0.393034826
#>  [21,] 0.046377081 0.13763287 0.597014925
#>  [22,] 0.378661340 0.82613038 0.313432836
#>  [23,] 0.943641748 0.76935542 0.442786070
#>  [24,] 0.862064635 0.01524617 0.582089552
#>  [25,] 0.111853298 0.72819999 0.791044776
#>  [26,] 0.075015775 0.24938792 0.955223881
#>  [27,] 0.680086325 0.35969223 0.800995025
#>  [28,] 0.388402706 0.77847338 0.492537313
#>  [29,] 0.332621981 0.82684786 0.945273632
#>  [30,] 0.142821369 0.20926869 0.651741294
#>  [31,] 0.462055764 0.75819951 0.636815920
#>  [32,] 0.915797444 0.89430587 0.323383085
#>  [33,] 0.528516890 0.01138526 0.044776119
#>  [34,] 0.113264123 0.84176718 0.333333333
#>  [35,] 0.214787029 0.43994683 0.308457711
#>  [36,] 0.584169262 0.41256290 0.029850746
#>  [37,] 0.889426962 0.14160522 0.318407960
#>  [38,] 0.182143077 0.10777208 0.074626866
#>  [39,] 0.210959314 0.52134645 0.482587065
#>  [40,] 0.762909208 0.49907083 0.218905473
#>  [41,] 0.819388645 0.69644069 0.696517413
#>  [42,] 0.212413467 0.73451556 0.009950249
#>  [43,] 0.685431760 0.99405830 0.900497512
#>  [44,] 0.459040822 0.06432488 0.014925373
#>  [45,] 0.433638127 0.56041064 0.268656716
#>  [46,] 0.524639397 0.89413246 0.114427861
#>  [47,] 0.815650246 0.41008304 0.512437811
#>  [48,] 0.966045799 0.23765252 0.676616915
#>  [49,] 0.734988999 0.36476995 0.208955224
#>  [50,] 0.832174050 0.59957481 0.666666667
#>  [51,] 0.204609023 0.65104985 0.592039801
#>  [52,] 0.454060696 0.06506076 0.950248756
#>  [53,] 0.814964983 0.35837218 0.681592040
#>  [54,] 0.153744759 0.93158613 0.472636816
#>  [55,] 0.318893935 0.84813229 0.139303483
#>  [56,] 0.126171371 0.38668510 0.228855721
#>  [57,] 0.342889169 0.20358914 0.398009950
#>  [58,] 0.895696301 0.85185811 0.522388060
#>  [59,] 0.182643564 0.86913618 0.517412935
#>  [60,] 0.856196686 0.20358412 0.860696517
#>  [61,] 0.741847270 0.29965912 0.890547264
#>  [62,] 0.867464799 0.69407020 0.507462687
#>  [63,] 0.230203873 0.48798681 0.980099502
#>  [64,] 0.330536810 0.60103199 0.039800995
#>  [65,] 0.541660008 0.15633184 0.199004975
#>  [66,] 0.726081048 0.53410237 0.671641791
#>  [67,] 0.884600142 0.78307306 0.915422886
#>  [68,] 0.832246714 0.65981930 0.288557214
#>  [69,] 0.532788138 0.71320290 0.706467662
#>  [70,] 0.494517612 0.78241738 0.820895522
#>  [71,] 0.325325809 0.30878492 0.457711443
#>  [72,] 0.711700335 0.98675537 0.109452736
#>  [73,] 0.575755820 0.78616851 0.124378109
#>  [74,] 0.058172195 0.38160260 0.467661692
#>  [75,] 0.677071724 0.86270528 0.417910448
#>  [76,] 0.787586533 0.60464655 0.990049751
#>  [77,] 0.177141192 0.15474022 0.885572139
#>  [78,] 0.803056951 0.25009276 0.975124378
#>  [79,] 0.009337459 0.90394281 0.751243781
#>  [80,] 0.908806033 0.59489162 0.134328358
#>  [81,] 0.228980210 0.17142359 0.701492537
#>  [82,] 0.003579189 0.59801860 0.995024876
#>  [83,] 0.424621959 0.28468871 0.248756219
#>  [84,] 0.326474493 0.62709004 0.985074627
#>  [85,] 0.183297016 0.95486250 0.169154229
#>  [86,] 0.727937452 0.11872782 0.825870647
#>  [87,] 0.189367298 0.03743877 0.726368159
#>  [88,] 0.077553409 0.24211130 0.621890547
#>  [89,] 0.703316851 0.33340687 0.572139303
#>  [90,] 0.426669608 0.84461066 0.303482587
#>  [91,] 0.042452132 0.11829118 0.432835821
#>  [92,] 0.815804883 0.27475569 0.189054726
#>  [93,] 0.819050662 0.59429581 0.328358209
#>  [94,] 0.300707426 0.98400735 0.298507463
#>  [95,] 0.706671629 0.86089884 0.348258706
#>  [96,] 0.595160181 0.23671284 0.293532338
#>  [97,] 0.524295829 0.86448095 0.477611940
#>  [98,] 0.061665250 0.48674753 0.850746269
#>  [99,] 0.868549532 0.31466049 0.343283582
#> [100,] 0.191746640 0.98666951 0.129353234
#> [101,] 0.016072558 0.81756254 0.358208955
#> [102,] 0.203730459 0.23625266 0.054726368
#> [103,] 0.577602849 0.87783144 0.835820896
#> [104,] 0.720810876 0.43061689 0.034825871
#> [105,] 0.498780903 0.34914441 0.641791045
#> [106,] 0.785459279 0.01100106 0.149253731
#> [107,] 0.071382093 0.71440986 0.875621891
#> [108,] 0.469698137 0.46153940 0.383084577
#> [109,] 0.286675284 0.24689494 0.711442786
#> [110,] 0.258172858 0.17498840 0.920398010
#> [111,] 0.875490184 0.34598553 0.741293532
#> [112,] 0.496164697 0.95265750 0.796019900
#> [113,] 0.796988362 0.32732380 0.532338308
#> [114,] 0.940382446 0.74369715 0.815920398
#> [115,] 0.868654662 0.03142394 0.805970149
#> [116,] 0.306695993 0.02544213 0.721393035
#> [117,] 0.363889574 0.95866755 0.179104478
#> [118,] 0.804204639 0.67499177 0.154228856
#> [119,] 0.234297809 0.26292950 0.756218905
#> [120,] 0.342660076 0.41755324 0.960199005
#> [121,] 0.417855432 0.33466245 0.407960199
#> [122,] 0.554832211 0.31320731 0.547263682
#> [123,] 0.529157121 0.17565539 0.646766169
#> [124,] 0.081273547 0.41225694 0.064676617
#> [125,] 0.910215794 0.85666723 0.656716418
#> [126,] 0.200800777 0.26397068 0.452736318
#> [127,] 0.461222639 0.62654196 0.781094527
#> [128,] 0.362309597 0.27944865 0.601990050
#> [129,] 0.141947120 0.26321053 0.388059701
#> [130,] 0.299877321 0.83040238 0.746268657
#> [131,] 0.699353506 0.52802666 0.855721393
#> [132,] 0.384963359 0.51817555 0.144278607
#> [133,] 0.868124438 0.79296263 0.059701493
#> [134,] 0.848135245 0.21638990 0.024875622
#> [135,] 0.068609437 0.99010411 0.527363184
#> [136,] 0.848180279 0.86511481 0.412935323
#> [137,] 0.255013857 0.11292935 0.079601990
#> [138,] 0.267979000 0.63982767 0.273631841
#> [139,] 0.953721487 0.21295952 0.830845771
#> [140,] 0.670913802 0.16335654 0.368159204
#> [141,] 0.923967443 0.88167811 0.930348259
#> [142,] 0.820139119 0.17334582 0.552238806
#> [143,] 0.800056496 0.64530265 0.363184080
#> [144,] 0.846568074 0.57317767 0.557213930
#> [145,] 0.537588823 0.96125810 0.776119403
#> [146,] 0.871887202 0.06576104 0.870646766
#> [147,] 0.642616371 0.35935059 0.502487562
#> [148,] 0.960013116 0.08335453 0.099502488
#> [149,] 0.483976776 0.49364645 0.049751244
#> [150,] 0.281682459 0.20255602 0.542288557
#> [151,] 0.502263678 0.55879782 0.164179104
#> [152,] 0.481301752 0.36260641 0.567164179
#> [153,] 0.823858663 0.51402344 0.845771144
#> [154,] 0.444499403 0.28414688 0.626865672
#> [155,] 0.777161526 0.63821185 0.373134328
#> [156,] 0.186096807 0.42682196 0.437810945
#> [157,] 0.397228541 0.23798799 0.910447761
#> [158,] 0.025060278 0.10565520 0.094527363
#> [159,] 0.724004350 0.77593414 0.213930348
#> [160,] 0.662069392 0.02997969 0.487562189
#> [161,] 0.961007127 0.30880630 0.233830846
#> [162,] 0.417589459 0.43046346 0.840796020
#> [163,] 0.601491618 0.28189736 0.203980100
#> [164,] 0.638832942 0.81222561 0.084577114
#> [165,] 0.344214296 0.21469887 0.497512438
#> [166,] 0.638569298 0.95934619 0.606965174
#> [167,] 0.968238574 0.66270991 0.691542289
#> [168,] 0.367097483 0.81902241 0.771144279
#> [169,] 0.158227543 0.06995628 0.402985075
#> [170,] 0.938258296 0.39287363 0.736318408
#> [171,] 0.086678059 0.15153523 0.587064677
#> [172,] 0.341096581 0.58632323 0.462686567
#> [173,] 0.035959240 0.71102405 0.895522388
#> [174,] 0.015781885 0.52399670 0.283582090
#> [175,] 0.610048787 0.82344041 0.965174129
#> [176,] 0.033026181 0.29745926 0.353233831
#> [177,] 0.221155767 0.34664544 0.089552239
#> [178,] 0.706951449 0.85572213 0.258706468
#> [179,] 0.732395660 0.92705590 0.611940299
#> [180,] 0.491927360 0.97601869 0.905472637
#> [181,] 0.923247206 0.67512781 0.970149254
#> [182,] 0.794832219 0.11270287 0.378109453
#> [183,] 0.205026672 0.50325255 0.427860697
#> [184,] 0.968347442 0.35350583 0.104477612
#> [185,] 0.085710260 0.06507651 0.338308458
#> [186,] 0.346173021 0.06147081 0.577114428
#> [187,] 0.416721608 0.99098812 0.119402985
#> [188,] 0.091607185 0.50546768 0.880597015
#> [189,] 0.362125723 0.78507410 0.253731343
#> [190,] 0.470002416 0.67255610 0.243781095
#> [191,] 0.708934926 0.04313264 0.631840796
#> [192,] 0.817451843 0.31846159 0.159203980
#> [193,] 0.551449715 0.08889390 0.238805970
#> [194,] 0.131351342 0.79434735 0.004975124
#> [195,] 0.691384633 0.92779151 0.562189055
#> [196,] 0.789317252 0.31668167 0.263681592
#> [197,] 0.745464500 0.15913167 0.422885572
#> [198,] 0.502357392 0.14797239 0.616915423
#> [199,] 0.828572205 0.24860242 0.761194030
#> [200,] 0.182625619 0.82333366 0.716417910