BoxCox: Box-Cox power transformation of a vector, adjusted to retain...

Description Usage Arguments Examples

View source: R/numerics.R

Description

Perform a power transformation on a numeric vector, retaining (by default) its mean and standard deviation. If two lamda values are given, this range is searched to find a power transformation parameter that minimises skewness. If x contains non-positive values, the vector is first shifted into the positive Reals before the transformation.

Usage

1
BoxCox(x, lamda = c(-5, 5), standardise = FALSE)

Arguments

x

a numeric vector

lamda

Either a single power parameter for the transformation or a vector of length 2 giving the range of lamda values to search to find an optimised transformation parameter.

standardise

logical. If TRUE, the returned value has mean=0 and SD=1. Otherwise (the default) the original mean and SD are retained.

Examples

1
2
3
x = rexp(50); xnew = BoxCox(x)
plot(x, xnew, ylab=paste0('BoxCox(x) used lamda=',signif(attr(xnew,'lamda'),4)))
qqnorm(BoxCox(x))

stevetnz/stevesRfunctions documentation built on May 28, 2019, 8:21 a.m.