poly(x, ...)
1
.
degree
that is a vector giving the degree of each column. When called with a single vector argument, there is an additional attribute
coefs
, which is a list with component names
alpha
and
norm2
.
The orthogonality of the polynomial is with respect to the data. For several arguments (vector, matrix, or both), each of the column vectors is used to generate orthogonal polynomials of the required degree. The columns will be a subset of the tensor product of the orthogonal polynomials of given degree of each for the individual variables.
The actual construction of the orthogonal basis is performed by the
poly.raw
function.
You can supply a
coefs
argument to the
poly
function that is used by
poly.raw
to determine the normalization constants used in constructing the orthogonal polynomials.
The
coefs
argument is used by
poly.raw
in the following manner:
Let the
j
th column of the output represent a polynomial
P(j)
, and define
P(-1)=0
and
P(0)=1
.
Then the orthogonal basis for the polynomials can be generated using the formula
P(j+1) = (x - alpha[j+1]) * P(j) - norm2[j+2]/norm2[j+1] * P(j-1)
.
The actual basis for the polynomials returned by
poly.raw
is the
P(j)
columns above scaled by their norms.
See the
poly.raw
help file for information on how these can be used to construct additional evaluations of the same polynomial basis.
The
poly.transform
function is used to transform coefficients for an orthogonal polynomial into coeffiecients for a standard polynomial representation.
For example, the coefficient estimates from a statistical model can be supplied, along with the orthogonal polynomial, to the
poly.transform
function to obtain the coefficient estimates for a standard polynomial representation.
See the help file for
poly.transform
for more information on the use of this function.
poly(freeny.y, 3) poly(freeny.y, freeny.x) poly(freeny.y, freeny.x, 2) glm(Kyphosis ~ poly(Age, 3) + Start, family=binomial, data=kyphosis) lm(NOx ~ poly(C, E, 4), data=ethanol)