[R] Coefficients in a polynomial glm with family poisson/binomial

1 view
Skip to first unread message

sam...@yahoo.fr

unread,
Oct 10, 2008, 12:30:01 PM10/10/08
to r-h...@r-project.org
Dear R-users

When running a glm polynomial model with one explanatory variable (example Y~X+X^2), with a poisson or binomial error distribution, the predicted values obtained from using the predict() function and those obtained from using the coefficients from the summary table "as is" in an equation of the form Y=INTERCEPT+ XCoef x X + XCoef x X^2, differ considerably. The former are correct and the latter are wrong.
This does not occur using lm() or in a glm with family as normal. I conclude that this is due to the link function, predict() having some way of back transforming the data. But if this is so, are the estimated coefficients wortheless in this case?
I need to get accurate coefficients (for use in another model using offset), and have resorted to re-estimating them by running a second polynomial (lm() this time) on the predicted values from predict() of the glm. This is clearly not a nice way of doing things.

Could anyone please inform me of why this is happening and of a better way around this?


Code:

glm2<-glm(FEDSTATUS1~AGE+I(AGE^2), family=binomial(link="probit"))
summary(glm2) ### first set of "wrong coefficients"

nd1<-expand.grid(AGE=c(1:70))
Pred.Fed1<-predict(glm2,nd1,type="response")
points(predict(glm2,nd1,type="response")~nd1$AGE, col=2)


AGE11<-c(11:70)
Pred<-t(rbind(Pred.Fed1,AGE11))
Pred<-as.data.frame(Pred)
model<-lm(Pred$Pred.Fed1~Pred$AGE11+I(Pred$AGE11^2))
summary(model) ### "accurate coefficients"


Thanks

Samuel Riou
University of Leeds

______________________________________________
R-h...@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.

Daniel Malter

unread,
Oct 10, 2008, 1:58:02 PM10/10/08
to sam...@yahoo.fr, r-h...@r-project.org
I don't know what you mean by XCoef x X. But your problem is (as it works if
you specify "normal" in a glm) that the functional relationship between your
predictors, i.e. Intercept+X+X^2, and Y is not linear for a binomial or a
poisson distribution.

Generalized linear model implies that the model is linear in the predictors.
It does not mean, however, that the functional relationship between the
linear predictor and Y is linear.

E.g. Y=exp(Intercept+X+X^2) is linear in the predictor, but it is a
nonlinear function because "e" is raised to the linear predictor. Consult
any book on generalized linear models for more help.

The estimated coefficients are typically not worthless as allow you to say
how much your Y will change with a change of delta*x at the mean of X, for
example, you just have to respect the functional form of the relationship
between X and Y. Thus, the coefficients you get are accurate. Just what you
do with them is not.

For the last part of your question, I am not sure what you are trying to do
there, but it does not sound right to me in the first place.

Cheers,
Daniel


-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: r-help-...@r-project.org [mailto:r-help-...@r-project.org] Im
Auftrag von sam...@yahoo.fr
Gesendet: Friday, October 10, 2008 12:30 PM
An: r-h...@r-project.org
Betreff: [R] Coefficients in a polynomial glm with family poisson/binomial

sam...@yahoo.fr

unread,
Oct 11, 2008, 6:17:51 AM10/11/08
to r-h...@r-project.org, Daniel Malter
Thanks for that Daniel,
Problem solved.
I was mis-specifying the equation, omitting that I had to account for the logit transformation used in family binomial.
i.e. had to write y~exp(b+ax+cx^2)/(1+exp(b+ax+cx^2)) to make use of the coeffs

The last part of what I was doing worked, running an lm on the predicted values of a glm, just to get coefficients that could be directly written in an equation of the form y~b+ax+cx^2. But was a silly way of going about it.

thank you

Samuel


--- En date de : Ven 10.10.08, Daniel Malter <dan...@umd.edu> a écrit :

Reply all
Reply to author
Forward
0 new messages