Compute Orthogonal Polynomials

Description

Returns or evaluates orthogonal polynomials of degree 1 to
degree over the specified set of points x. These are all
orthogonal to the constant polynomial of degree 0. Alternatively,
evaluate raw polynomials.

Usage

Arguments

a numeric vector at which to evaluate the
polynomial. x can also be a matrix. Missing values are not
allowed in x.

degree

the degree of the polynomial

coefs

for prediction, coefficients from a previous fit.

raw

if true, use raw and not orthogonal polynomials.

object

an object inheriting from class "poly", normally
the result of a call to poly with a single vector argument.

...

poly, polym: further vectors.predict.poly: arguments to be passed to or from other methods.

Details

Although formally degree should be named (as it follows
...), an unnamed second argument of length 1 will be
interpreted as the degree.

The orthogonal polynomial is summarized by the coefficients, which can
be used to evaluate it via the three-term recursion given in Kennedy
& Gentle (1980, pp. 343–4), and used in the “predict” part of
the code.

Value

For poly with a single vector argument:
A matrix with rows corresponding to points in x and columns
corresponding to the degree, with attributes "degree" specifying
the degrees of the columns and (unless raw = TRUE)
"coefs" which contains the centering and normalization
constants used in constructing the orthogonal polynomials. The matrix
has given class c("poly", "matrix").
Other cases of poly and polym, and predict.poly:
a matrix.

Note

This routine is intended for statistical purposes such as
contr.poly: it does not attempt to orthogonalize to
machine accuracy.