Skip to contents

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.

Usage

rosenblatt(x, model, cores = 1, randomize_discrete = TRUE)

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).

randomize_discrete

Whether to randomize the transform for discrete variables; see Details.

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 - j + 1, j]} | V_{M[d - j, j]}, \dots, V_{M[1, j]}), $$ where \(M\) is the structure matrix. Similarly, inverse_rosenblatt() returns $$ V_{M[d + 1- j, j]}= F^{-1}(U_{M[d - j + 1, j]} | U_{M[d - j, j]}, \dots, U_{M[1, j]}). $$

If some variables have atoms, Brockwell (10.1016/j.spl.2007.02.008) proposed a simple randomization scheme to ensure that output is still independent uniform if the model is correct. The transformation reads $$ U_{M[d - j, j]}= W_{d - j} F(V_{M[d - j, j]} | V_{M[d - j - 1, j - 1]}, \dots, V_{M[0, 0]}) + (1 - W_{d - j}) F^-(V_{M[d - j, j]} | V_{M[d - j - 1, j - 1]}, \dots, V_{M[0, 0]}), $$ where \(F^-\) is the left limit of the conditional cdf and \(W_1, \dots, W_d\) are are independent standard uniform random variables. This is used by default. If you are interested in the conditional probabilities $$ F(V_{M[d - j, j]} | V_{M[d - j - 1, j - 1]}, \dots, V_{M[0, 0]}), $$ set randomize_discrete = FALSE.

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.942622023 0.406448652 0.805970149
#>   [2,] 0.349913863 0.743128670 0.213930348
#>   [3,] 0.585578222 0.322713885 0.601990050
#>   [4,] 0.730948980 0.536569385 0.527363184
#>   [5,] 0.633889240 0.271682743 0.024875622
#>   [6,] 0.850240428 0.017356181 0.835820896
#>   [7,] 0.581600258 0.433203134 0.751243781
#>   [8,] 0.672664583 0.844026063 0.716417910
#>   [9,] 0.841337978 0.229553452 0.039800995
#>  [10,] 0.338367818 0.287550374 0.681592040
#>  [11,] 0.591956491 0.228051587 0.114427861
#>  [12,] 0.489201431 0.066062013 0.930348259
#>  [13,] 0.966547642 0.436825881 0.268656716
#>  [14,] 0.394712966 0.919258759 0.910447761
#>  [15,] 0.668173329 0.831601803 0.457711443
#>  [16,] 0.022348282 0.109862215 0.820895522
#>  [17,] 0.793849371 0.206690408 0.194029851
#>  [18,] 0.623059673 0.998773113 0.383084577
#>  [19,] 0.916290791 0.156485414 0.432835821
#>  [20,] 0.182442456 0.215046778 0.278606965
#>  [21,] 0.485682118 0.468301198 0.094527363
#>  [22,] 0.274338914 0.806642601 0.567164179
#>  [23,] 0.702642445 0.449817900 0.492537313
#>  [24,] 0.308492449 0.946658753 0.368159204
#>  [25,] 0.839360862 0.532575866 0.895522388
#>  [26,] 0.527891996 0.281785872 0.412935323
#>  [27,] 0.041560535 0.741006979 0.452736318
#>  [28,] 0.632308937 0.508833578 0.815920398
#>  [29,] 0.624048979 0.807217467 0.756218905
#>  [30,] 0.940383524 0.953516452 0.636815920
#>  [31,] 0.662370527 0.407228597 0.980099502
#>  [32,] 0.636283607 0.590291276 0.402985075
#>  [33,] 0.117790317 0.545472933 0.283582090
#>  [34,] 0.967777369 0.247559303 0.577114428
#>  [35,] 0.712050584 0.958291865 0.004975124
#>  [36,] 0.607257278 0.262469037 0.318407960
#>  [37,] 0.089696160 0.952032655 0.074626866
#>  [38,] 0.336806241 0.190604493 0.830845771
#>  [39,] 0.084364615 0.978899653 0.223880597
#>  [40,] 0.677240145 0.821821082 0.358208955
#>  [41,] 0.274917966 0.496861235 0.950248756
#>  [42,] 0.891085523 0.709192685 0.661691542
#>  [43,] 0.297058393 0.456048065 0.990049751
#>  [44,] 0.472129911 0.677972825 0.034825871
#>  [45,] 0.001235758 0.975310850 0.179104478
#>  [46,] 0.313081891 0.166245570 0.825870647
#>  [47,] 0.877340477 0.399369123 0.641791045
#>  [48,] 0.214148380 0.648779469 0.477611940
#>  [49,] 0.289281601 0.466453039 0.547263682
#>  [50,] 0.117840703 0.585959596 0.800995025
#>  [51,] 0.348889925 0.496090764 0.786069652
#>  [52,] 0.300857099 0.073093674 0.104477612
#>  [53,] 0.284376764 0.679675939 0.925373134
#>  [54,] 0.007456045 0.868069413 0.144278607
#>  [55,] 0.906998403 0.089296646 0.218905473
#>  [56,] 0.306669187 0.157650085 0.472636816
#>  [57,] 0.155856813 0.118379281 0.741293532
#>  [58,] 0.416742579 0.525073303 0.850746269
#>  [59,] 0.737369864 0.535654550 0.303482587
#>  [60,] 0.782679980 0.381042893 0.462686567
#>  [61,] 0.452935820 0.456392253 0.691542289
#>  [62,] 0.605438113 0.792330019 0.651741294
#>  [63,] 0.995552961 0.160372369 0.606965174
#>  [64,] 0.327109807 0.691818740 0.885572139
#>  [65,] 0.536491230 0.043873893 0.582089552
#>  [66,] 0.384721861 0.154319005 0.616915423
#>  [67,] 0.829495835 0.974036611 0.437810945
#>  [68,] 0.273028094 0.029271472 0.900497512
#>  [69,] 0.768826860 0.226347281 0.129353234
#>  [70,] 0.577827011 0.027326539 0.860696517
#>  [71,] 0.088096323 0.217744958 0.611940299
#>  [72,] 0.379310115 0.008495693 0.159203980
#>  [73,] 0.739123372 0.222756266 0.701492537
#>  [74,] 0.898298540 0.332932637 0.084577114
#>  [75,] 0.740965523 0.254798563 0.273631841
#>  [76,] 0.198404580 0.769835858 0.646766169
#>  [77,] 0.671285757 0.536969611 0.880597015
#>  [78,] 0.114740550 0.023068205 0.686567164
#>  [79,] 0.558470247 0.103792205 0.915422886
#>  [80,] 0.471423939 0.032168715 0.696517413
#>  [81,] 0.426648753 0.336383843 0.099502488
#>  [82,] 0.119355570 0.026226962 0.343283582
#>  [83,] 0.177401855 0.615622015 0.029850746
#>  [84,] 0.655818006 0.470001114 0.442786070
#>  [85,] 0.899233814 0.278302619 0.497512438
#>  [86,] 0.542113177 0.639042793 0.288557214
#>  [87,] 0.449462774 0.160549722 0.995024876
#>  [88,] 0.794722642 0.381438067 0.975124378
#>  [89,] 0.610829331 0.735909871 0.706467662
#>  [90,] 0.478884343 0.910398560 0.313432836
#>  [91,] 0.095228141 0.130391516 0.537313433
#>  [92,] 0.301617325 0.818770801 0.865671642
#>  [93,] 0.186656808 0.919942297 0.184079602
#>  [94,] 0.195253286 0.263112314 0.631840796
#>  [95,] 0.215669306 0.115822936 0.766169154
#>  [96,] 0.157629042 0.720903102 0.064676617
#>  [97,] 0.314232188 0.156424209 0.243781095
#>  [98,] 0.780490240 0.707514974 0.557213930
#>  [99,] 0.824372886 0.679786090 0.323383085
#> [100,] 0.640973271 0.511055869 0.467661692
#> [101,] 0.670804099 0.373595085 0.487562189
#> [102,] 0.143314939 0.182247594 0.517412935
#> [103,] 0.213545873 0.683768896 0.308457711
#> [104,] 0.043560306 0.821328281 0.671641791
#> [105,] 0.545308190 0.805912313 0.019900498
#> [106,] 0.621213733 0.373772609 0.258706468
#> [107,] 0.473557102 0.042025848 0.009950249
#> [108,] 0.974231998 0.599159159 0.960199005
#> [109,] 0.919732864 0.814321139 0.855721393
#> [110,] 0.640620565 0.520644621 0.532338308
#> [111,] 0.999456836 0.928057476 0.069651741
#> [112,] 0.227204584 0.650795014 0.263681592
#> [113,] 0.595376846 0.614441732 0.447761194
#> [114,] 0.210914392 0.068111143 0.502487562
#> [115,] 0.923140884 0.255157865 0.711442786
#> [116,] 0.453717712 0.677193024 0.731343284
#> [117,] 0.341313363 0.161015871 0.054726368
#> [118,] 0.304425804 0.471496436 0.293532338
#> [119,] 0.967939679 0.695461581 0.089552239
#> [120,] 0.880163296 0.541478608 0.134328358
#> [121,] 0.818306527 0.333732585 0.253731343
#> [122,] 0.025406332 0.729088182 0.626865672
#> [123,] 0.251502152 0.853213157 0.044776119
#> [124,] 0.139422688 0.369272216 0.845771144
#> [125,] 0.935122032 0.235771639 0.203980100
#> [126,] 0.899248950 0.107379375 0.417910448
#> [127,] 0.929205414 0.179133476 0.726368159
#> [128,] 0.304797019 0.539321374 0.507462687
#> [129,] 0.400830429 0.415682431 0.875621891
#> [130,] 0.586750259 0.725756545 0.298507463
#> [131,] 0.050265134 0.778968950 0.781094527
#> [132,] 0.301450649 0.179632936 0.388059701
#> [133,] 0.423399866 0.062649357 0.208955224
#> [134,] 0.847628545 0.778793183 0.338308458
#> [135,] 0.491724039 0.880503646 0.676616915
#> [136,] 0.387890424 0.911518819 0.353233831
#> [137,] 0.247463922 0.534272897 0.393034826
#> [138,] 0.958748770 0.763123278 0.945273632
#> [139,] 0.306073937 0.363752786 0.164179104
#> [140,] 0.130042874 0.365263078 0.587064677
#> [141,] 0.798244939 0.394730627 0.049751244
#> [142,] 0.263976039 0.035329791 0.363184080
#> [143,] 0.792652100 0.182596922 0.522388060
#> [144,] 0.707757379 0.337367450 0.597014925
#> [145,] 0.174972832 0.703483314 0.373134328
#> [146,] 0.820518170 0.533613888 0.407960199
#> [147,] 0.695690551 0.872061901 0.427860697
#> [148,] 0.266796358 0.318881975 0.149253731
#> [149,] 0.787826496 0.749496470 0.791044776
#> [150,] 0.671649317 0.921199674 0.840796020
#> [151,] 0.235524595 0.517347774 0.552238806
#> [152,] 0.272650508 0.401716575 0.348258706
#> [153,] 0.576659257 0.785799061 0.014925373
#> [154,] 0.636907294 0.225867121 0.079601990
#> [155,] 0.125970868 0.534350935 0.985074627
#> [156,] 0.110715313 0.197146959 0.248756219
#> [157,] 0.024531282 0.738076879 0.398009950
#> [158,] 0.633345299 0.883469856 0.796019900
#> [159,] 0.594275376 0.183046676 0.870646766
#> [160,] 0.304284197 0.799634576 0.656716418
#> [161,] 0.748497848 0.284848551 0.955223881
#> [162,] 0.399899523 0.134553954 0.562189055
#> [163,] 0.760611767 0.670283847 0.746268657
#> [164,] 0.418835009 0.389248618 0.810945274
#> [165,] 0.338021375 0.045204946 0.174129353
#> [166,] 0.531017284 0.989414681 0.169154229
#> [167,] 0.062137970 0.205129484 0.059701493
#> [168,] 0.862788832 0.648885214 0.238805970
#> [169,] 0.795821987 0.316408409 0.890547264
#> [170,] 0.337392247 0.240934080 0.109452736
#> [171,] 0.702456126 0.660290023 0.940298507
#> [172,] 0.308076401 0.150286222 0.333333333
#> [173,] 0.817394719 0.931328775 0.189054726
#> [174,] 0.705430955 0.942915114 0.592039801
#> [175,] 0.575558120 0.449949724 0.233830846
#> [176,] 0.908330272 0.384990612 0.119402985
#> [177,] 0.393921007 0.853002392 0.621890547
#> [178,] 0.301009768 0.723641978 0.935323383
#> [179,] 0.909833101 0.558928773 0.124378109
#> [180,] 0.996878334 0.939215546 0.736318408
#> [181,] 0.264995450 0.977445389 0.970149254
#> [182,] 0.330058330 0.875358171 0.920398010
#> [183,] 0.341329020 0.076805668 0.199004975
#> [184,] 0.852442315 0.683058413 0.422885572
#> [185,] 0.273082749 0.873584730 0.482587065
#> [186,] 0.440108976 0.269988950 0.965174129
#> [187,] 0.648942498 0.962631728 0.512437811
#> [188,] 0.248470658 0.738143558 0.572139303
#> [189,] 0.030511764 0.621355315 0.771144279
#> [190,] 0.198629584 0.254167609 0.139303483
#> [191,] 0.925028071 0.806701463 0.761194030
#> [192,] 0.324325292 0.605207040 0.542288557
#> [193,] 0.910207893 0.194573847 0.228855721
#> [194,] 0.638744671 0.893062830 0.905472637
#> [195,] 0.108594070 0.843619246 0.328358209
#> [196,] 0.071551051 0.838391474 0.721393035
#> [197,] 0.064549491 0.706072267 0.666666667
#> [198,] 0.084391980 0.213514964 0.154228856
#> [199,] 0.613927291 0.890045351 0.378109453
#> [200,] 0.103952659 0.278702928 0.776119403