poly.transform
Transform Coefficients from Orthogonal Polynomial Form

Description

Returns the vector of coefficients for the polynomial in simple form when given the coefficients for the orthogonal form.

Usage

poly.transform(polymat, coefs, intercept = TRUE)

Arguments

polymat an object that is the output of the poly function. In particular, this must have a "coefs" attribute.
coefs a vector of coefficients for the polynomial in orthogonal form. The order of these must be the coefficient for the intercept (if intercept is TRUE), and then the coefficients in the order implied by polymat.

intercept a logical flag. If TRUE (the default), then the coefs argument is assumed to include the intercept term.

Details

This function works only when poly is given a single vector with which to form a polynomial.
Use poly because the regression can become ill-conditioned (hence inaccurate) when the straightforward approach is used.
Value
returns a vector of coefficients for the polynomial in simple form. That is, the first element is the constant term, the second element is the coefficient for x, the third element is the coefficient for x squared, and so on. Notice that even if intercept is FALSE, an intercept term is returned by poly.transform().
See Also
poly, lm
Examples
d <- data.frame(y=1:16, x=log(1:16))
cPoly <- coef(lm(y~poly(x,3), data=d)) # Orthogonal polynomial
cPoly
coef(lm(y~x+I(x^2)+I(x^3), data=d)) # Naive monomials
poly.transform(poly(d$x,3), cPoly) # Orthogonal -> Naive
Package splusUtils version 6.1.1-7
Package Index