Learn R Programming

Transform (version 1.0)

lgTransform: Log Transformation for Normality

Description

lgTransform performs Log transformation for normality of a variable and provides graphical analysis.

Usage

lgTransform(data, lambda2 = NULL, plot = TRUE, alpha = 0.05, verbose = TRUE)

Value

A list with class "lg" containing the following elements:

method

method name

lambda2

additional shifting parameter

statistic

Shapiro-Wilk test statistic for transformed data

p.value

Shapiro-Wilk test p.value for transformed data

alpha

level of significance to assess normality

tf.data

transformed data set

var.name

variable name

Arguments

data

a numeric vector of data values.

lambda2

a numeric for an additional shifting parameter. Default is set to lambda2 = NULL.

plot

a logical to plot histogram with its density line and qqplot of raw and transformed data. Defaults plot = TRUE.

alpha

the level of significance to check the normality after transformation. Default is set to alpha = 0.05.

verbose

a logical for printing output to R console.

Author

Muge Coskun Yildirim, Osman Dag

Details

Denote \(y\) the variable at the original scale and \(y'\) the transformed variable. The Log power transformation is defined by:

$$y' = \log(y)$$

If the data include any nonpositive observations, a shifting parameter \(\lambda_2\) can be included in the transformation given by:

$$y' = \log(y+\lambda_2)$$

References

Asar, O., Ilk, O., Dag, O. (2017). Estimating Box-Cox Power Transformation Parameter via Goodness of Fit Tests. Communications in Statistics - Simulation and Computation, 46:1, 91--105.

Box, G.E., Cox, D.R. (1964). An Analysis of Transformations. Journal of the Royal Statistical Society: Series B (Methodological), 26:2, 211--43.

Examples

Run this code


data <- cars$dist

library(Transform)
out <- lgTransform(data)
out$p.value # p.value of Shapiro-Wilk test for transformed data 
out$tf.data # transformed data set


Run the code above in your browser using DataLab