mesmer.stats.YeoJohnsonTransformer.inverse_transform

mesmer.stats.YeoJohnsonTransformer.inverse_transform#

YeoJohnsonTransformer.inverse_transform(yearly_pred, monthly_residuals, lambda_coeffs, time_dim='time')#

apply the inverse power transformation using the fitted lambdas.

Parameters:
  • yearly_pred (xr.DataArray) – yearly values used as predictors for the lambdas, must contain time_dim but can have additional dimensions for example gridcells or members.

  • monthly_residuals (xr.DataArray) – The data to be transformed back to the original scale. Has time_dim which is of length yearly_pred[time_dim].size * 12 and can also contain the same additional dimensions as yearly_pred.

  • lambda_coeffs (xr.DataArray) – DataArray containing the estimated coefficients needed to compute lambda with dimensions “month”, “coeff” and additional dims on inputs. Calculated using lambda_function.

  • time_dim (str, default: “time”) – Name of the time dimension in the input data used to align monthly residuals and yearly predictor data (needs to be the same in both).

Returns:

xr.Dataset – Dataset containing the inverted monthly residuals and the parameters of the power transformation for each gridcell.

Notes

The inverse of the Yeo-Johnson transformation is given by:

if \(X_{trans} \leq 0\) and \(\lambda = 0\):

\(X_{inv} = exp(X_{trans}) - 1\)

elif \(X_{trans} \leq 0\) and \(\lambda \neq 0\):

\(X_{inv} = (X_{trans} \cdot \lambda + 1)^{\frac{1}{\lambda} - 1}\)

elif \(X_{trans} < 0\) and \(\lambda \neq 2\):

\(X_{inv} = 1 - ((\lambda - 2) \cdot X_{trans} + 1)^{\frac{1}{2 - \lambda}}\)

elif \(X_{trans} < 0\) and \(\lambda = 2\):

\(X_{inv} = 1 - exp(-X_{trans})\)

Note that \(X_{inv}\) and \(X_{trans}\) have the same sign.