On Tue, 14 Jul 2009, Lars Bergemann wrote:

Hi. Thanks for your help with my previous question (comparing two lm() models with a maximum likelihood ratio test)

I had a look at lrtest from the package lmtest as it has been suggested to me, but I am not 100% sure if that is the right thing to do ...

That clearly depends on what you consider to be "right".

In any case, lrtest() computes (in an object-oriented way) -2 times the loglikelihood difference and compares that with a chi-squared distribution with the corresponding degrees of freedom (difference in df of the models).

lrtest uses the same log likelihoods as you can extract by hand from lm() with logLik - are this the maximum log likelihoods?

It's the maximized log-likelihood. Thus, it's the sum of (normal) log-densities, evaluated at the observations and the estimated parameters.

How does R calculate them? I tried google to find information about that, but I could not find anything of interest.

I assume that you read help("logLik.lm")? If all else fails, looking at the code of stats:::logLik.lm should also help. In essence, it is
  0.5 * (sum(log(w)) - N * (log(2 * pi) + 1 - log(N) +
    log(sum(w * res^2))))
where all variables have the obvious meaning.
Z

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to