Description Usage Arguments Details Value Author(s) Examples
Estimates the parameter lamnda of the Box-Cox function thanks to least squares.
1 | BoxCox_lm(Y,X)
|
Y |
List of real numbers |
X |
List of real numbers |
X and Y must have the same dimension.
Returns the estimated parameter lambda with the method of least squares applied to the linear regression between Y and X.
Marion
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
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.