[R] problem with logLik and offsets

From: Jarrod Hadfield <j.hadfield_at_sheffield.ac.uk>
Date: Wed 03 Jan 2007 - 18:39:18 GMT


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. Received on Thu Jan 04 05:45:50 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:25 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.