mesmer.stats.inverse_yeo_johnson_transform

mesmer.stats.inverse_yeo_johnson_transform#

mesmer.stats.inverse_yeo_johnson_transform(yearly_pred, monthly_residuals, lambda_coeffs)#

apply the inverse power transformation using the fitted lambdas.

Parameters:
  • yearly_pred (xr.DataArray of shape (n_years, n_gridcells)) – yearly values used as predictors for the lambdas.

  • monthly_residuals (xr.DataArray of shape (n_years, n_gridcells)) – The data to be transformed back to the original scale.

  • lambda_coeffs (xr.DataArray) – The parameters of the power transformation of shape (months, coeff, n_gridcells) for each gridcell, calculated using lambda_function.

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.