Hello-

In the notes for the lm function it states " Offsets specified by offset will not be included in predictions by predict.lm, whereas those specified by an offset term in the formula will be." I would like to extract fitted values in just this way from a glm model, those with the offset and those without. I have tried doing things like this:

predict.glm(glm(Incident~Numbers, offset=logit(Numbers), family=binomial, data=violdata))

predict.glm(glm(Incident~Numbers+offset(logit(Numbers)), family=binomial, data=violdata))

As well as like this:

glm(Incident~Numbers, offset=logit(Numbers), family=binomial, data=violdata)$fitted.values

glm(Incident~Numbers+offset(logit(Numbers)), family=binomial, data=violdata)$fitted.values

But they return the same result. The first 50 lines of my data look like this:

structure(list(Incident = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), Numbers = c(13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L)), .Names = c("Incident",
"Numbers"), row.names = c(NA, 50L), class = "data.frame")


Any assistance gratefully recieved.

Many thanks,
Chris Beeley, Institute of Mental Health, UK

______________________________________________
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