sqrt_x: sqrt(x + a) Normalization

View source: R/sqrt_x.R

sqrt_xR Documentation

sqrt(x + a) Normalization

Description

Perform a sqrt (x+a) normalization transformation

Usage

sqrt_x(x, a = NULL, standardize = TRUE, ...)

## S3 method for class 'sqrt_x'
predict(object, newdata = NULL, inverse = FALSE, ...)

## S3 method for class 'sqrt_x'
print(x, ...)

Arguments

x

A vector to normalize with with x

a

The constant to add to x (defaults to max(0, -min(x)))

standardize

If TRUE, the transformed values are also centered and scaled, such that the transformation attempts a standard normal

...

additional arguments

object

an object of class 'sqrt_x'

newdata

a vector of data to be (potentially reverse) transformed

inverse

if TRUE, performs reverse transformation

Details

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.

Value

A list of class sqrt_x with elements

x.t

transformed original data

x

original data

mean

mean after transformation but prior to standardization

sd

sd after transformation but prior to standardization

n

number of nonmissing observations

norm_stat

Pearson's P / degrees of freedom

standardize

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.

Examples

x <- rgamma(100, 1, 1)

sqrt_x_obj <- sqrt_x(x)
sqrt_x_obj
p <- predict(sqrt_x_obj)
x2 <- predict(sqrt_x_obj, newdata = p, inverse = TRUE)

all.equal(x2, x)


petersonR/bestNormalize documentation built on March 15, 2024, 9:29 a.m.