box_cox_transform: Box-Cox Transformation

Description Usage Arguments Value Class Attributes Class Methods Details Examples

Description

Conduct Box-Cox Transformation. This can be used as

Transformation parameters can be fixed by users, or estimated by the maximum likelihood.

Usage

1
2
box_cox_transform(lambda = 1, lambda2 = NULL,
  skipfit = FALSE, tol = 1e-5)

Arguments

lambda

initial value for lambda parameter

lambda2

initial value for lambda2 parameter or logical that indicates if lambda2 should be estimated. If NULL or FALSE, then lambda2 is fixed to 0

skipfit

logical. If TRUE, fit method does nothing and the parameters are fixed to the initial values.

tol

lambda smaller than this level is regarded as 0 and log function is applied

Value

BoxCoxTransform class object

Class Attributes

beta

regression coefficients

Class Methods

fit(x = NULL, y)

if skipfit is FALSE, then estimate the lambda parameter(s) by the maximum likelihood, otherwise, the parameters are fixed. In either case, regression coeffients beta are estimated by the least squares

transform(x = NULL, y)

transform y and returns list of x and y

inv_transform(x = NULL, y)

inverse transform y and returns list of x and y

predict(x, ...)

return predicted values of y in the pre-transfom scale

incr_fit(x, y)

not available

Details

uses boxcoxfit as the backend paramter estimator

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
simul <- geoR::rboxcox(100, lambda=0.5, mean=10, sd=2)
b <- box_cox_transform()
b$fit(y=simul)
cat(b$lambda, '\n')

b <- box_cox_transform(lambda2=TRUE)
b$fit(y=seq(-1, 1, 1/20))
cat(b$lambda, b$lambda2, '\n')

data(trees)
b <- box_cox_transform()
x <- trees[,1:2]
y <- trees[,3]
b$fit(x, y)
pred <- b$predict(x)$y
cor(y, pred)
## Not run: 
plot(y, pred)
## End(Not run)

b <- box_cox_transform(lambda=0, skipfit=TRUE)
b$fit(y=1:10)
cat(b$lambda, b$beta, '\n')

kota7/MLPipe documentation built on May 5, 2019, 5:53 p.m.