yeo_johnson_transform: Determine Best Parameter for Yeo-Johnson Transform

View source: R/S05_Statistics.R

yeo_johnson_transformR Documentation

Determine Best Parameter for Yeo-Johnson Transform

Description

Estimates and applies best-fitting Yeo-Johnson transformation parameter via maximum likelihood for a vector of numeric values.

Usage

yeo_johnson_transform(x, lower = -100, upper = 100)

Arguments

x

A numeric vector (values can be positive, negative, or zero).

lower

The smallest value for the transformation parameter to consider.

upper

The highest value for the transformation parameter to consider.

Details

The transformation parameter to use is estimated via maximum likelihood using the base:optimize and stats:dnorm functions.

Value

A numeric vector, the transformed values of x.

References

Yeo, I. K., & Johnson, R. A. (2000). A new family of power transformations to improve normality or symmetry. Biometrika, 87 (4), 954-959. https://doi.org/10.1093/biomet/87.4.954

Examples

# Example from page 958 of Yeo & Johnson (2000)
x <- c(
  6.1, -8.4, 1.0, 2.0, 0.7, 2.9, 3.5,
  5.1, 1.8, 3.6, 7.0, 3.0, 9.3, 7.5, -6.0
)
shapiro.test( x ) # Test of normality
x_transformed <- yeo_johnson_transform(x)
# Extract results of maximum likelihood estimation
attributes(x_transformed)$mle_for_yeo_johnson
shapiro.test( x_transformed ) # Test of normality shows improvement


rettopnivek/arfpam documentation built on Oct. 20, 2024, 7:24 p.m.