trafo_lm {trafo}R Documentation

Fits transformed linear models

Description

Function trafo_lm fits linear models with transformed dependent variable. The main return are two lm objects where one is the untransformed linear model and the other one the transformed linear model.

Usage

trafo_lm(object, trafo = "boxcox", lambda = "estim", method = "ml",
  lambdarange = NULL, std = FALSE, custom_trafo = NULL)

Arguments

object

an object of type lm.

trafo

a character string. Different transformations can be used for transforming the dependent variable in a linear model: (i) "bickeldoksum", (ii) "boxcox", (iii) "dual", (iv) "glog", (v) "gpower", (vi) "log", (vii) "logshiftopt", (viii) "manly", (ix) "modulus", (x) "neglog", (xi) "reciprocal", (xii) "yeojohnson". Defaults to "boxcox".

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 which means that the default value of the chosen transformation is used.

std

logical. If TRUE, the transformed model is returned based on the standardized/scaled transformation. Defaults to FALSE.

custom_trafo

a list. The list has two elements where the first element is a function specifying the desired transformation and the second element is a function specifying the corresponding standardized transformation. Defaults to NULL.

Value

An object of class trafo_lm. Methods such as diagnostics.trafo_lm, print.trafo_lm, plot.trafo_lm and summary.trafo_lm can be used for this class.

See Also

bickeldoksum, boxcox, dual, glog, gpower, log, logshiftopt, manly, modulus, neglog, sqrtshift, yeojohnson

Examples

# Load data
data("cars", package = "datasets")

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

# Compare untransformed and transformed model
trafo_lm(object = lm_cars, trafo = "bickeldoksum", method = "skew", 
lambdarange = c(1e-11, 2))

[Package trafo version 1.0.1 Index]