1
$\begingroup$

I have an outcome which may be transformed in cases of egregious departures from normality to its Box-Cox optimal normal transformation in an unconditional model.

How is the likelihood calculated for the $\lambda$ parameter?

For instance, if I generate data according to a skewnormal model:

set.seed(123)
y <- rlnorm(100, 1, 1)
x <- rep(1, 100)
o <- boxcox(y ~ x)

I get as the optimal $\lambda$ a value close to 0 as expected which achieves a maximum of $\log(L(x, y,\lambda)) \approx -200$ .

enter image description here

However, when I evaluate the log-likelihood of the log transformed response using logLik(glm(y ~ 1, family=gaussian(link=log))) the value is:

'log Lik.' -295.7451 (df=2)

I would expect those values to be the same.

$\endgroup$
1

1 Answer 1

1
$\begingroup$

In the source code for getS3method('boxcox', 'default'). It seems what they call the log-likelihood is calculated like this

loglik[i] <- -n/2 * log(sum(qr.resid(xqr, yt)^2))

whereas logLik.lm uses

val <- 0.5 * (sum(log(w)) - N * (log(2 * pi) + 1 - log(N) + log(sum(w * res^2))))

which if we have unity weights is equivalent to

val <- 0.5 * ( - N * (log(2 * pi) + 1 - log(N) + log(sum(res^2))))

so basically the boxcox procedure drops the additive constant of 0.5 * ( - N * (log(2 * pi) + 1 - log(N))), which gives the same optimal solution, but the graphic is incorrect in that the raw values are not the actual log-likelihood.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.