invertYJ | R Documentation |
Once a Yeo-Johnson transformation has been applied, is may be useful to un-transform the data to recover the raw data. See examples.
invertYJ(xt, lambda, interval = c(-1e+10, 1e+10), keepMedian = T, keepMAD = T)
xt |
Transformed values of data |
lambda |
Lambda value that had transformed data into xt |
interval |
Interval in which to look for data. If search is difficult, restricting the search to plausible values should help. |
keepMedian |
Logical. Should the original data's median be kept? |
keepMAD |
Logical. Should the original data's MAD be kept? |
Because YeoJohn
defaults to retaining the default median and MAD of the original data,
it is not trivial to simply apply the Yeo-Johnson lambda "in reverse." Instead, this function
uses 1-dimensional OLS optimization to find the vector of data that has the same median and mean as
the transformed data, but also has the lambda applied "in reverse." Such optimization has limits, however;
both YeoJohn
and invertYJ
will work best on relatively small values (e.g., absolute
values less than 1000) and on datasets with more than 10 numbers or so.
x <- 1:10
x1 <- VGAM::yeo.johnson(x,2)
x_recovered <- invertYJ(x1,2)
d <- rnorm(10,3) + rexp(10,4)
d1 <- ACmisc::YeoJohn(d)
invertYJ(attr(d1,'transformedDat'),attr(d1,'lambda'),interval = c(-1e3,1E3)) # fails if there is too large of an interval.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.