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)
#>                 V1         V2          V3
#>   [1,] 0.830481587 0.43979351 0.890547264
#>   [2,] 0.537516232 0.30021550 0.412935323
#>   [3,] 0.044593319 0.78248071 0.447761194
#>   [4,] 0.618584524 0.40098854 0.815920398
#>   [5,] 0.602277704 0.83488704 0.756218905
#>   [6,] 0.939472981 0.92899249 0.631840796
#>   [7,] 0.660034395 0.39016889 0.975124378
#>   [8,] 0.662103587 0.60066679 0.402985075
#>   [9,] 0.132073192 0.54321512 0.273631841
#>  [10,] 0.967372809 0.12086653 0.572139303
#>  [11,] 0.751370914 0.88727138 0.004975124
#>  [12,] 0.619770380 0.27334545 0.323383085
#>  [13,] 0.112219721 0.82606863 0.074626866
#>  [14,] 0.339463529 0.14348764 0.830845771
#>  [15,] 0.095389222 0.96766627 0.218905473
#>  [16,] 0.690535935 0.86117846 0.368159204
#>  [17,] 0.295657552 0.46392694 0.940298507
#>  [18,] 0.896734561 0.64047103 0.656716418
#>  [19,] 0.336401993 0.45544033 0.985074627
#>  [20,] 0.503480143 0.56540104 0.034825871
#>  [21,] 0.001019291 0.84925625 0.184079602
#>  [22,] 0.324262386 0.12781189 0.820895522
#>  [23,] 0.883340820 0.24182485 0.636815920
#>  [24,] 0.224989578 0.72354979 0.477611940
#>  [25,] 0.314080610 0.49046341 0.542288557
#>  [26,] 0.116230810 0.72549321 0.805970149
#>  [27,] 0.351893794 0.50433248 0.791044776
#>  [28,] 0.333348757 0.07567987 0.099502488
#>  [29,] 0.287609947 0.74039690 0.915422886
#>  [30,] 0.007589545 0.60793987 0.139303483
#>  [31,] 0.921352963 0.08525318 0.213930348
#>  [32,] 0.319994212 0.20918588 0.472636816
#>  [33,] 0.150909123 0.15776453 0.746268657
#>  [34,] 0.422157205 0.46788371 0.845771144
#>  [35,] 0.761161774 0.54180050 0.298507463
#>  [36,] 0.799107917 0.30028021 0.462686567
#>  [37,] 0.476287045 0.40596196 0.691542289
#>  [38,] 0.620952318 0.81574840 0.646766169
#>  [39,] 0.993632890 0.10137867 0.597014925
#>  [40,] 0.332266414 0.72876883 0.880597015
#>  [41,] 0.559620534 0.05527248 0.577114428
#>  [42,] 0.427381931 0.14489078 0.606965174
#>  [43,] 0.843048641 0.97550606 0.432835821
#>  [44,] 0.286577173 0.02817389 0.895522388
#>  [45,] 0.800807497 0.26617908 0.119402985
#>  [46,] 0.572887156 0.01939254 0.855721393
#>  [47,] 0.098297814 0.30225299 0.601990050
#>  [48,] 0.368977555 0.02382475 0.159203980
#>  [49,] 0.708521187 0.13868920 0.711442786
#>  [50,] 0.914565661 0.33986175 0.084577114
#>  [51,] 0.758829780 0.25432027 0.268656716
#>  [52,] 0.210872153 0.86715046 0.641791045
#>  [53,] 0.665514014 0.43324957 0.875621891
#>  [54,] 0.127177797 0.05921286 0.681592040
#>  [55,] 0.569458222 0.05342952 0.905472637
#>  [56,] 0.471383178 0.03932244 0.706467662
#>  [57,] 0.461491280 0.36774017 0.094527363
#>  [58,] 0.110079976 0.04971222 0.353233831
#>  [59,] 0.222843516 0.33971397 0.029850746
#>  [60,] 0.687133772 0.43670728 0.437810945
#>  [61,] 0.892528019 0.17486607 0.497512438
#>  [62,] 0.577827241 0.68906621 0.278606965
#>  [63,] 0.516820981 0.15534359 0.990049751
#>  [64,] 0.803366661 0.39393168 0.965174129
#>  [65,] 0.604858234 0.72078354 0.716417910
#>  [66,] 0.497079733 0.94454404 0.308457711
#>  [67,] 0.099332256 0.20623280 0.532338308
#>  [68,] 0.313948355 0.87242467 0.860696517
#>  [69,] 0.191360049 0.89860918 0.189054726
#>  [70,] 0.213846149 0.29886364 0.626865672
#>  [71,] 0.234996611 0.11715176 0.766169154
#>  [72,] 0.183898971 0.52438532 0.064676617
#>  [73,] 0.321999460 0.22817872 0.238805970
#>  [74,] 0.790425232 0.67197946 0.557213930
#>  [75,] 0.835060634 0.68110936 0.328358209
#>  [76,] 0.666421811 0.49262843 0.467661692
#>  [77,] 0.690221055 0.30151489 0.492537313
#>  [78,] 0.151164154 0.25378443 0.517412935
#>  [79,] 0.217337172 0.72400690 0.303482587
#>  [80,] 0.045003228 0.93559562 0.666666667
#>  [81,] 0.532256995 0.67822696 0.024875622
#>  [82,] 0.649879892 0.39620089 0.258706468
#>  [83,] 0.528692896 0.01977060 0.009950249
#>  [84,] 0.953705796 0.78001959 0.950248756
#>  [85,] 0.899588714 0.78945109 0.850746269
#>  [86,] 0.672154455 0.50391345 0.527363184
#>  [87,] 0.999465539 0.92552429 0.069651741
#>  [88,] 0.216268906 0.68829218 0.263681592
#>  [89,] 0.635264115 0.64084093 0.442786070
#>  [90,] 0.214341645 0.12705131 0.502487562
#>  [91,] 0.912078002 0.12806247 0.721393035
#>  [92,] 0.460480296 0.66911264 0.736318408
#>  [93,] 0.369219188 0.11754563 0.054726368
#>  [94,] 0.320326960 0.51219347 0.288557214
#>  [95,] 0.975868660 0.72486413 0.089552239
#>  [96,] 0.895452101 0.56702616 0.129353234
#>  [97,] 0.839165104 0.29940961 0.253731343
#>  [98,] 0.022796006 0.85271455 0.621890547
#>  [99,] 0.309877844 0.68755056 0.039800995
#> [100,] 0.154138828 0.38418516 0.840796020
#> [101,] 0.946311641 0.17360914 0.203980100
#> [102,] 0.911179649 0.06347573 0.417910448
#> [103,] 0.928440367 0.08098487 0.731343284
#> [104,] 0.325075963 0.59101815 0.507462687
#> [105,] 0.385898614 0.34682714 0.870646766
#> [106,] 0.622219541 0.77613711 0.293532338
#> [107,] 0.049313103 0.92022443 0.781094527
#> [108,] 0.316707629 0.23872032 0.388059701
#> [109,] 0.436528847 0.10858195 0.208955224
#> [110,] 0.858753792 0.78572587 0.348258706
#> [111,] 0.514555115 0.91308092 0.671641791
#> [112,] 0.383236548 0.94559512 0.363184080
#> [113,] 0.261363579 0.59693757 0.393034826
#> [114,] 0.950157334 0.84135976 0.930348259
#> [115,] 0.320297774 0.38055222 0.164179104
#> [116,] 0.139921979 0.43699953 0.582089552
#> [117,] 0.824261766 0.43002304 0.044776119
#> [118,] 0.259280671 0.07898543 0.373134328
#> [119,] 0.802511455 0.10815119 0.522388060
#> [120,] 0.723334121 0.24788667 0.592039801
#> [121,] 0.168088532 0.75193023 0.378109453
#> [122,] 0.835822494 0.50430382 0.407960199
#> [123,] 0.720523836 0.90034032 0.427860697
#> [124,] 0.291356297 0.33443905 0.144278607
#> [125,] 0.781822887 0.68247814 0.796019900
#> [126,] 0.679702226 0.88908725 0.835820896
#> [127,] 0.252356260 0.57799504 0.552238806
#> [128,] 0.268064298 0.44948477 0.358208955
#> [129,] 0.614640776 0.64798521 0.014925373
#> [130,] 0.644425934 0.28448735 0.079601990
#> [131,] 0.151187675 0.61615902 0.980099502
#> [132,] 0.121924183 0.20284644 0.243781095
#> [133,] 0.026277002 0.73128825 0.398009950
#> [134,] 0.611567863 0.88472404 0.800995025
#> [135,] 0.602790317 0.09238793 0.865671642
#> [136,] 0.328610768 0.86273950 0.651741294
#> [137,] 0.730410581 0.22411853 0.945273632
#> [138,] 0.413913064 0.14955650 0.562189055
#> [139,] 0.744743734 0.60844353 0.751243781
#> [140,] 0.423560591 0.33852124 0.810945274
#> [141,] 0.317951611 0.07307936 0.179104478
#> [142,] 0.546060051 0.99157011 0.169154229
#> [143,] 0.061540615 0.06295529 0.059701493
#> [144,] 0.888925591 0.67423478 0.233830846
#> [145,] 0.788060804 0.19071426 0.885572139
#> [146,] 0.369499153 0.23627903 0.104477612
#> [147,] 0.728122692 0.60790436 0.925373134
#> [148,] 0.303497900 0.23175080 0.343283582
#> [149,] 0.822384277 0.95789948 0.194029851
#> [150,] 0.721004257 0.95093246 0.587064677
#> [151,] 0.596994666 0.49740107 0.228855721
#> [152,] 0.926601129 0.38670499 0.109452736
#> [153,] 0.430245406 0.89575652 0.616915423
#> [154,] 0.333113201 0.78426945 0.920398010
#> [155,] 0.927566871 0.58124720 0.114427861
#> [156,] 0.994665956 0.94852048 0.741293532
#> [157,] 0.313790749 0.97926621 0.960199005
#> [158,] 0.332005161 0.91330159 0.910447761
#> [159,] 0.330937115 0.12403329 0.199004975
#> [160,] 0.861523677 0.64018595 0.422885572
#> [161,] 0.272359138 0.92561468 0.487562189
#> [162,] 0.472771692 0.17085771 0.955223881
#> [163,] 0.674376890 0.97162522 0.512437811
#> [164,] 0.270922734 0.83523479 0.567164179
#> [165,] 0.031456819 0.80077737 0.771144279
#> [166,] 0.237413156 0.22386117 0.134328358
#> [167,] 0.918535994 0.74941557 0.761194030
#> [168,] 0.342900977 0.66911882 0.537313433
#> [169,] 0.927153390 0.15244154 0.223880597
#> [170,] 0.632898275 0.85505677 0.900497512
#> [171,] 0.109882666 0.85622685 0.333333333
#> [172,] 0.068325519 0.93823211 0.726368159
#> [173,] 0.069848325 0.83735766 0.661691542
#> [174,] 0.100411286 0.14086801 0.149253731
#> [175,] 0.625952995 0.93119076 0.383084577
#> [176,] 0.103056237 0.35102686 0.776119403
#> [177,] 0.708924735 0.44000894 0.313432836
#> [178,] 0.168827381 0.25381374 0.935323383
#> [179,] 0.037696364 0.65171687 0.825870647
#> [180,] 0.930341310 0.32884446 0.248756219
#> [181,] 0.395141766 0.14070196 0.283582090
#> [182,] 0.245299016 0.29696413 0.019900498
#> [183,] 0.698801240 0.72686556 0.338308458
#> [184,] 0.793500606 0.54638252 0.686567164
#> [185,] 0.025578224 0.08782937 0.676616915
#> [186,] 0.292958220 0.84275705 0.482587065
#> [187,] 0.253935348 0.26263805 0.318407960
#> [188,] 0.480654276 0.85629793 0.049751244
#> [189,] 0.915582927 0.06762914 0.174129353
#> [190,] 0.661215690 0.71651908 0.970149254
#> [191,] 0.826526489 0.36140022 0.696517413
#> [192,] 0.500949996 0.98323718 0.124378109
#> [193,] 0.535308955 0.19836781 0.154228856
#> [194,] 0.806291365 0.67149462 0.995024876
#> [195,] 0.101227476 0.25375003 0.452736318
#> [196,] 0.054736355 0.67985293 0.701492537
#> [197,] 0.449814844 0.22619102 0.547263682
#> [198,] 0.840435312 0.72483164 0.611940299
#> [199,] 0.715438662 0.34104866 0.457711443
#> [200,] 0.880856168 0.45084832 0.786069652