Creates polynomial variables, to be used in regression. Will create polynomials of degree less than
or equal to the degree specified, and will mean center variables by default.
Usage
polynomial(x, degree = 2, center = mean(x, na.rm = TRUE))
Value
A matrix containing the linear
splines.
Arguments
x
variable used to create the
polynomials.
degree
the maximum degree
polynomial to be returned. Polynomials of degree <= degree will be
returned.
# Reading in a datasetdata(mri)
# Create a polynomial on ldlpolynomial(mri$ldl, degree=3)
# Use a polynomial in regressregress("mean", atrophy ~ polynomial(age, degree = 2), data = mri)