Displaying 1 result from an estimated 1 matches for "xlbar".
Did you mean:
lbar
2006 Oct 11
3
for loop not working in function
...ters to resources for learning to write functions in R for
neophyte programmers? Thanks. --Dale
boxcox <- function(x,min,max,step) {
lambda <- seq(min,max,step)
s <- length(lambda)
for (lambda in 1:s)
n <- nrow(x)
if(lambda ==0) xL <- log(x) else
xL <- ((x^lambda) - 1)/lambda
xLbar <- mean(xL)
t1 <- (-n/2)* log((1/n)*sum((xL - xLbar)^2))
t2 <- (lambda - 1)*sum(log(x))
l= t1 + t2
l
}