logshiftopt: Log shift opt transformation for linear models

Description Usage Arguments Value Examples

View source: R/logshiftopt.R

Description

The function transforms the dependent variable of a linear model using the Log shift opt transformation. The transformation parameter can either be estimated using different estimation methods or given.

Usage

1
2
logshiftopt(object, lambda = "estim", method = "ml",
  lambdarange = NULL, plotit = TRUE)

Arguments

object

an object of type lm.

lambda

either a character named "estim" if the optimal transformation parameter should be estimated or a numeric value determining a given value for the transformation parameter. Defaults to "estim".

method

a character string. Different estimation methods can be used for the estimation of the optimal transformation parameter: (i) Maximum likelihood approach ("ml"), (ii) Skewness minimization ("skew"), (iii) Kurtosis optimization ("kurt"), (iv) Divergence minimization by Kolmogorov-Smirnov ("div.ks"), by Cramer-von-Mises ("div.cvm") or by Kullback-Leibler ("div.kl"). Defaults to "ml".

lambdarange

a numeric vector with two elements defining an interval that is used for the estimation of the optimal transformation parameter. Defaults to NULL. In this case the lambdarange is set to the range of the data. In case the lowest value is negative the absolute value of the lowest value plus 1 is the lower bound for the range.

plotit

logical. If TRUE, a plot that illustrates the optimal transformation parameter or the given transformation parameter is returned. Defaults to TRUE.

Value

An object of class trafo. Methods such as as.data.frame.trafo and print.trafo can be used for this class.

Examples

1
2
3
4
5
6
7
8
9
# Load data
data("cars", package = "datasets")

# Fit linear model
lm_cars <- lm(dist ~ speed, data = cars)

# Transform dependent variable using divergence minimization following
# Kolmogorov-Smirnof
logshiftopt(object = lm_cars, method = "div.ks", plotit = FALSE)

Example output

Registered S3 method overwritten by 'pryr':
  method      from
  print.bytes Rcpp
The default lambdarange for the Log shift opt transformation is calculated dependent on the data range. The lower value is set to -1 and the upper value to 118

Log shift opt Transformation 

Estimation method:  div.ks  
Optimal parameter:  34.8243  
Divergence:  0.0771 

Summary of transformed variables 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  3.606   4.108   4.260   4.302   4.509   5.042 

trafo documentation built on May 2, 2019, 2:13 p.m.

Related to logshiftopt in trafo...