Perform a sqrt (x+a) normalization transformation
A vector to normalize with with x
The constant to add to x (defaults to max(0, -min(x)))
If TRUE, the transformed values are also centered and scaled, such that the transformation attempts a standard normal
additional arguments
an object of class 'sqrt_x'
a vector of data to be (potentially reverse) transformed
if TRUE, performs reverse transformation
A list of class sqrt_x
with elements
transformed original data
original data
mean after transformation but prior to standardization
sd after transformation but prior to standardization
number of nonmissing observations
Pearson's P / degrees of freedom
was the transformation standardized
The predict
function returns the numeric value of the transformation
performed on new data, and allows for the inverse transformation as well.
sqrt_x
performs a simple square-root transformation in the
context of bestNormalize, such that it creates a transformation that can be
estimated and applied to new data via the predict
function. The
parameter a is essentially estimated by the training set by default
(estimated as the minimum possible), while the base
must be specified beforehand.
x <- rgamma(100, 1, 1)
sqrt_x_obj <- sqrt_x(x)
sqrt_x_obj
#> Standardized sqrt(x + a) Transformation with 100 nonmissing obs.:
#> Relevant statistics:
#> - a = 0
#> - mean (before standardization) = 0.9442748
#> - sd (before standardization) = 0.451784
p <- predict(sqrt_x_obj)
x2 <- predict(sqrt_x_obj, newdata = p, inverse = TRUE)
all.equal(x2, x)
#> [1] TRUE