# Re: [R] glm expand model to more values

From: Charles Annis, P.E. <Charles.Annis_at_statisticalengineering.com>
Date: Sat, 12 Jan 2008 13:39:01 -0500

What is wrong is that half of your parameter estimates are statistically meaningless:

dd <- data.frame(a=c(1, 2, 3, 4, 5, 6), b=c(3, 5, 6, 7, 9, 10))

overparameterized.model <- glm(b~poly(a,3),data=dd)

summary(overparameterized.model)

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 6.6667 0.1725 38.644 0.000669 ***

poly(a, 3)1 5.7371 0.4226 13.576 0.005382 **

poly(a, 3)2 -0.1091 0.4226 -0.258 0.820395

poly(a, 3)3 0.2236 0.4226 0.529 0.649562

Charles Annis, P.E.

Hi

I have the problem with fitting curve to data with lm and glm. When I use polynominal dependiency, fitted values from model are OK, but I cannot recive proper values when I use coefficents to caltulate this. Let me present simple example:

I have simple data.frame: (dd)

1. 1 2 3 4 5 6
2. 3 5 6 7 9 10

I try to fit it to model:

model=glm(b~poly(a,3),data=dd)
I have following data fitted to model (as I expected)
> fitted(model)

and coef(model)
(Intercept) poly(a, 3)1 poly(a, 3)2 poly(a, 3)3   6.6666667 5.7370973 -0.1091089 0.2236068

so when I try to expand the model to other data (simple extrapolation), let say: s=seq(1:10,by=1)

I do:
extra=sapply(s,function(x) coef(model) %*% x^(0:3)) and here is result:
[1] 12.51826 19.49328 28.93336 42.18015 60.57528 85.46040 118.17714  [8] 160.06715 212.47207 276.73354

the data form expanding coefs are completly differnd from fitted

What's going wrong?

Jarek

R-help_at_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.

R-help_at_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. Received on Sat 12 Jan 2008 - 18:47:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 Jan 2008 - 19:30:06 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.