dOTC | R Documentation |
Perform a multivariate (non stationary) bias correction.
Three random variables are needed, Y0, X0 and X1. The dynamic between X0 and X1 is estimated, and applied to Y0 to estimate Y1. Finally, OTC is used between X1 and the Y1 estimated.
SBCK::OTC
-> dOTC
new()
Create a new dOTC object.
dOTC$new( bin_width = NULL, bin_origin = NULL, cov_factor = "std", ot = SBCK::OTNetworkSimplex$new() )
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
cov_factor
[string or matrix] Covariance factor to correct the dynamic transferred between X0 and Y0. For string, available values are "std" and "cholesky"
ot
[OTSolver] Optimal Transport solver, default is the network simplex
A new 'dOTC' object.
fit()
Fit the bias correction method
dOTC$fit(Y0, X0, X1)
Y0
[matrix: n_samples * n_features] Observations in calibration
X0
[matrix: n_samples * n_features] Model in calibration
X1
[matrix: n_samples * n_features] Model in projection
NULL
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 = dotc$bin_width / 2 >> n = base::prod(base::dim(X1)) >> Z1 = dotc$predict(X1) >> Z1 = Z1 + t(matrix(stats::runif( n = n min = - bw , max = bw ) , ncol = dim(X1)[1] )) are equivalent for OTC.
dOTC$predict(X1, X0 = NULL)
X1
[matrix: n_samples * n_features] Model in projection
X0
[matrix: n_samples * n_features or NULL] Model in calibration
[matrix or list] Return the matrix of correction of X1 if X0 is NULL, else return a list containing Z1 and Z0, the corrections of X1 and X0
clone()
The objects of this class are cloneable with this method.
dOTC$clone(deep = FALSE)
deep
Whether to make a deep clone.
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
## Three 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
X1 = XY$X1 ## Biased in projection period
## Bin length
bin_width = c(0.2,0.2)
## Bias correction
## Step 1 : construction of the class dOTC
dotc = SBCK::dOTC$new( bin_width )
## Step 2 : Fit the bias correction model
dotc$fit( Y0 , X0 , X1 )
## Step 3 : perform the bias correction, Z is a list containing
## corrections
Z = dotc$predict(X1,X0)
Z$Z0 ## Correction in calibration period
Z$Z1 ## Correction in projection period
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.