normalize: Transform a variable to obtain approximate normality

View source: R/normalize.R

normalizeR Documentation

Transform a variable to obtain approximate normality

Description

(Slow) implementation of the transformation described in Albada, 2007.

Usage

normalize(X, na.rm = FALSE)

Arguments

X

the vector of values

na.rm

should the NA values be ignored when estimating the cumulative distribution function.

References

Albada et al. Transformation of arbitrary distributions to the normal distribution with application to EEG test-retest reliability (2007, journal of Neuroscience Methods)

Examples


n <- 1000

## normal distribution ##
X <- rnorm(n)
Xnorm <- normalize(X)
shapiro.test(Xnorm)
# plot(X, Xnorm)

X.NA <- c(NA,X,NA)
Xnorm.NA <- normalize(X.NA, na.rm = TRUE)

## gamma distribution
X <- rgamma(n, shape = 1)
shapiro.test(X)
# hist(X)

Xnorm <- normalize(X)
shapiro.test(Xnorm)
# hist(Xnorm)
# plot(X,Xnorm)

bozenne/butils documentation built on Oct. 14, 2023, 6:19 a.m.