BoxCox_lm: Box-Cox parameter lambda's estimation with Least Squares

Description Usage Arguments Details Value Author(s) Examples

Description

Estimates the parameter lamnda of the Box-Cox function thanks to least squares.

Usage

1
BoxCox_lm(Y,X)

Arguments

Y

List of real numbers

X

List of real numbers

Details

X and Y must have the same dimension.

Value

Returns the estimated parameter lambda with the method of least squares applied to the linear regression between Y and X.

Author(s)

Marion

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
BoxCox_lm(log(-log(seq(500,1)/1e6)),log(tail(sort(rlnorm(1e6)),500)))

## The function is currently defined as
function (x)
{
  f <- function(lambda) {
    if(lambda == 0)
      X <- log(X)
    else
      X <- (X**lambda - 1)/lambda

    b <-  cov(X,Y) / var(X)
    a <- mean(Y) - b*mean(X)
    sum( (Y - a - b*X)**2 )
  }
  optimize(f,c(0,1))$minimum
  }

genostats/tail.modeling documentation built on May 12, 2019, 7:42 a.m.