Re: [R] problem with logLik and offsets

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 05 Jan 2007 - 19:10:30 GMT

The problem is with residuals in model3.

Fixed in 2.4.1 patched and later.

On Wed, 3 Jan 2007, Jarrod Hadfield wrote:

> Hi,
>
> I'm trying to compare models, one of which has all parameters fixed
> using offsets. The log-likelihoods seem reasonble in all cases except
> the model in which there are no free parameters (model3 in the toy
> example below). Any help would be appreciated.
>
> Cheers,
>
> Jarrod
>
> x<-rnorm(100)
> y<-rnorm(100, 1+x)
>
> model1<-lm(y~x)
> logLik(model1)
> sum(dnorm(y, predict(model1), summary(model1)$sigma,log=TRUE))
>
> # no offset - in agreement
>
> model2<-lm(y~offset(rep(1,100))+x-1)
> logLik(model2)
> sum(dnorm(y, predict(model2),summary(model2)$sigma,log=TRUE))
>
> # offset and free parameters - in agreement
>
> model3<-lm(y~offset(rep(1,100))+offset(x)-1)
> logLik(model3)
> sum(dnorm(y, predict(model3),summary(model3)$sigma,log=TRUE))
>
> # offset only - discrepancy
>
> sum(predict(model3)-c(1+x))
>
> # yet predict is correct
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Sat Jan 06 12:02:02 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 06 Jan 2007 - 01:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.