OTC {SBCK}R Documentation

OTC (Optimal Transport Correction) method

Description

Perform a multivariate bias correction of X0 with respect to Y0.

Details

Joint distribution, i.e. all dependence are corrected.

Public fields

bin_width

[vector or NULL] A vector of lengths of the cells discretizing R^numbers of variables. If NULL, it is estimating during the fit

bin_origin

[vector or NULL] Coordinate of lower corner of one cell. If NULL, c(0,...,0) is used

muX

[SparseHist] Histogram of the data from the model

muY

[SparseHist] Histogram of the data from the observations

ot

[OTSolver] Optimal Transport solver, default is the network simplex

plan

[matrix] The plan computed by the ot solver.

n_features

[integer] Numbers of features

Methods

Public methods


Method new()

Create a new OTC object.

Usage
OTC$new(bin_width = NULL, bin_origin = NULL, ot = SBCK::OTNetworkSimplex$new())
Arguments
bin_width

[vector or NULL] A vector of lengths of the cells discretizing R^numbers of variables. If NULL, it is estimating during the fit

bin_origin

[vector or NULL] Coordinate of lower corner of one cell. If NULL, c(0,...,0) is used

ot

[OTSolver] Optimal Transport solver, default is the network simplex

Returns

A new 'OTC' object.


Method fit()

Fit the bias correction method

Usage
OTC$fit(Y0, X0)
Arguments
Y0

[matrix: n_samples * n_features] Observations in calibration

X0

[matrix: n_samples * n_features] Model in calibration

Returns

NULL


Method predict()

Predict the correction

Note: Only the center of the bins associated to the corrected points are returned, but all corrections of the form: >> bw = otc$bin_width / 2 >> n = base::prod(base::dim(X0)) >> Z0 = otc$predict(X0) >> Z0 = Z0 + t(matrix(stats::runif( n = n min = - bw , max = bw ) , ncol = dim(X0)[1] )) are equivalent for OTC.

Usage
OTC$predict(X0)
Arguments
X0

[matrix: n_samples * n_features or NULL] Model in calibration

Returns

[matrix] Return the corrections of X0


Method clone()

The objects of this class are cloneable with this method.

Usage
OTC$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

Robin, Y., Vrac, M., Naveau, P., Yiou, P.: Multivariate stochastic bias corrections with optimal transport, Hydrol. Earth Syst. Sci., 23, 773–786, 2019, https://doi.org/10.5194/hess-23-773-2019

Examples

## Two bivariate random variables (rnorm and rexp are inverted between ref 
## and bias)
XY = SBCK::dataset_gaussian_exp_2d(2000)
X0 = XY$X0 ## Biased in calibration period
Y0 = XY$Y0 ## Reference in calibration period

## Bin length
bin_width = SBCK::bin_width_estimator( list(X0,Y0) )

## Bias correction
## Step 1 : construction of the class OTC 
otc = SBCK::OTC$new( bin_width ) 
## Step 2 : Fit the bias correction model
otc$fit( Y0 , X0 )
## Step 3 : perform the bias correction, Z0 is the correction of
## X0 with respect to the estimation of Y0
Z0 = otc$predict(X0)


[Package SBCK version 1.0.0 Index]