Description Usage Arguments Details Value Examples
r2d2
applies the R2D2 algorithm to correct the dependence structure
of the (previously univariately corrected) bc1d
dataset.
1 |
refdata |
A matrix of dimension |
bc1d |
A matrix of dimension |
icond |
A vector of integers giving the indices of the variables
in |
lag_search |
An integer corresponding to the number of time lags to account for
when searching in |
lag_keep |
An integer corresponding to the number of time lags to keep in the correction
for each best analogue of rank associations found.
|
This function performs the R2D2 rank resampling conditionnaly to the conditioning dimensions,
to correct the dependence structure of the P
variables of a dataset bc1d
in terms of rank (i.e. copula). The resulting dependence structure is adjusted with respect
to dependence structure of the reference dataset, refdata
.
The dataset bc1d
contains data whose P
variables have
already been corrected by a univariate (1D) bias-correction method. Note that bc1d
and
refdata
must not have any NA values.
Ideally, the number of time steps in the bc1d
dataset and in the
refdata
reference dataset should be equal (T = T_refdata
).
If this is not the case, the ranks of the largest dataset are shrinked
so that both datasets have the same maximal rank.
For the full reference, see : Vrac, M. Multivariate bias adjustment of high-dimensional climate simulations: the Rank Resampling for Distributions and Dependences (R2D2) Bias Correction. Hydrol. Earth Syst. Sci., 22, 3175-3196, https://doi.org/10.5194/hess-22-3175-2018
A list with the following elements:
ranks_ref A matrix of dimension T_ref x P
with the ranks of refdata
ranks_bc1d A matrix of dimension T x P
with the ranks of bc1d
sorted_bc1d A matrix of dimension min(T, T_ref) x P
with the sorted values of bc1d
that are available
for the correction. if T > T_ref
the number of possible value
for correction per variable is shrunk to T_ref
r2d2_bc A matrix of dimension T x P
with
the bc1d
data corrected by the R2D2 bias-correction method
visited_time A vector of length T_ref
with the number of times
that the rank of a specific time step in refdata
at time T_ref[i]
has been resampled to create r2d2_bc
.
time_bestanalogue A vector indentifying the time indices of the best rank association analogues found in refdata
for each block of conditioning dimensions.
The time index of the best analogue corresponds to the last time step of the rank association block.
dist_bestanalogue A vector with the euclidean distances between the rank associations in bc1d
and the best analogues found in refdata
for each block of conditioning dimensions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # Reproducing the example provided in Vrac (2018)
refdata <- matrix(c(0.3, 0.5, 0.9, 0.8,
1.1, 1.7, 1.2, 1.9,
2.1, 1.8, 3.0, 2.7), ncol = 3, nrow = 4)
bc1d <- matrix(c(0.7, 0.5, 0.2, 0.9,
1.3, 1.8, 1.1, 1.4,
1.9, 2.9, 2.0, 2.6), ncol = 3, nrow = 4)
# 1 conditioning dimension, 0 lag
r2d2(refdata = refdata,
bc1d = bc1d,
icond = 1)
r2d2(refdata = refdata,
bc1d = bc1d,
icond = 2)
r2d2(refdata = refdata,
bc1d = bc1d,
icond = 3)
# 1 conditioning dimension, 1 lag search, 1 lag keep
r2d2(refdata = refdata,
bc1d = bc1d,
icond = 1,
lag_search = 1,
lag_keep = 1)
# 2 conditioning dimensions, 1 lag search, 1 lag keep
r2d2(refdata = refdata,
bc1d = bc1d,
icond = 1:2,
lag_search = 1,
lag_keep = 1)
# with climate data
data("r2d2_example")
# conditioning dimension: temperature in Paris
r2d2_correction <- r2d2(
refdata = r2d2_example$refdata,
bc1d = r2d2_example$bc1d,
icond = 1,
lag_search = 8, lag_keep = 6 )
# conditioning dimension: temperature and precipitation in Paris
r2d2_correction <- r2d2(
refdata = r2d2_example$refdata,
bc1d = r2d2_example$bc1d,
icond = c(1, 6),
lag_search = 8, lag_keep = 6 )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.