Learn R Programming

bestNormalize (version 1.9.1)

double_reverse_log: Double Reverse Log(x + a) Transformation

Description

First reverses scores, then perform a log_b(x) normalization transformation, and then reverses scores again.

Usage

double_reverse_log(
  x,
  b = 10,
  standardize = TRUE,
  eps = diff(range(x, na.rm = TRUE))/10,
  warn = TRUE,
  ...
)

# S3 method for double_reverse_log predict(object, newdata = NULL, inverse = FALSE, ...)

# S3 method for double_reverse_log print(x, ...)

Value

A list of class double_reverse_log 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

b

estimated base b value

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.

Arguments

x

A vector to normalize with with x

b

The base of the log (defaults to 10)

standardize

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

eps

The cushion for the transformation range (defaults to 10 percent)

warn

Should a warning result from infinite values?

...

additional arguments

object

an object of class 'double_reverse_log'

newdata

a vector of data to be (potentially reverse) transformed

inverse

if TRUE, performs reverse transformation

Details

double_reverse_log performs a simple log 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 to some extent epsilon), while the base must be specified beforehand.

Examples

Run this code
x <- rgamma(100, 1, 1)

double_reverse_log_obj <- double_reverse_log(x)
double_reverse_log_obj
p <- predict(double_reverse_log_obj)
x2 <- predict(double_reverse_log_obj, newdata = p, inverse = TRUE)

all.equal(x2, x)

Run the code above in your browser using DataLab