Learn R Programming

rigr (version 1.0.7)

polynomial: Create Polynomials

Description

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.

center

the value to center the polynomials at.

Examples

Run this code

# Reading in a dataset
data(mri)

# Create a polynomial on ldl
polynomial(mri$ldl, degree=3)

# Use a polynomial in regress
regress("mean", atrophy ~ polynomial(age, degree = 2), data = mri)

Run the code above in your browser using DataLab