[R] problem with logLik and offsets

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jan 5 20:10:30 CET 2007


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 at 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 at 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



More information about the R-help mailing list