Hello,

I have a question regarding fitting a polynomial to a data set, then 
constructing a polynom from the coefficients so that I can integrate it. I 
first use lm to fit the polynomial setting the coefficients to raw=TRUE - 
this appears to work fine. I plot the model and it is a true 
representation of the data.
I then take the coefficients vector and construct a polynom from the 
library(PolynomF) package. When I plot this the generated line is not 
representative of the data. The polynomial intercept is correct, however 
the gradient is well below the actual dataset, and does not follow the 
same contour. 
A code snippet and output are provided below. Any help would be much 
appreciated.
Thanks,
Blaise.

lddata.mdl <- lm(lddata[,2]~poly(lddata[,1],9,raw=TRUE)) 
lddata.ply <- polynom(lddata.mdl$coefficients);
lddata.int <- integral(lddata.ply);
plot(lddata[,1],lddata[,2],pch=".")
lines(predict(lddata.ply,timeseq),col=4,lwd=2,lty=1)
lines(predict(lddata.mdl,newdata=list(timeseq=x)),col=4,lwd=2,lty=1)


The coefficients from lddata.mdl are:
(Intercept) poly(lddata[, 1], 9, raw = TRUE)1 
                    -4.714865e+05                      1.054330e+06 
poly(lddata[, 1], 9, raw = TRUE)2 poly(lddata[, 1], 9, raw = TRUE)3 
                    -1.855263e+05                      2.397431e+04 
poly(lddata[, 1], 9, raw = TRUE)4 poly(lddata[, 1], 9, raw = TRUE)5 
                    -1.692492e+03                      6.492181e+01 
poly(lddata[, 1], 9, raw = TRUE)6 poly(lddata[, 1], 9, raw = TRUE)7 
                    -1.335839e+00                      1.393105e-02 
poly(lddata[, 1], 9, raw = TRUE)8 poly(lddata[, 1], 9, raw = TRUE)9 
                    -7.284687e-05                      3.200856e-07
The output from the lddata.ply is:
-471486.5 + 1054330*x - 185526.3*x^2 + 23974.31*x^3 - 1692.492*x^4 + 
64.92181*x^5 - 1.335839*x^6 + 0.01393105*x^7 - 7.284687e-05*x^8 + 
3.200856e-07*x^9

---

This e-mail may contain confidential and/or privileged i...{{dropped:8}}


