Transforms a numeric vector of values using the Yeo-Johnson (2000) power transformation family.

yeo_johnson(y, lambda)

Arguments

y

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

lambda

A numeric value specifying the transformation to apply.

Value

A numeric vector.

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)
y <- 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( y ) # Test of normality
#> 
#> 	Shapiro-Wilk normality test
#> 
#> data:  y
#> W = 0.8994, p-value = 0.09319
#> 
y_transformed <- yeo_johnson(y, 1.305)
shapiro.test( y_transformed ) # Test of normality shows improvement
#> 
#> 	Shapiro-Wilk normality test
#> 
#> data:  y_transformed
#> W = 0.97474, p-value = 0.921
#>