polynomial: Create Polynomials

View source: R/polynomial.R

polynomialR Documentation

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))

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.

Value

A matrix containing the linear splines.

Examples


# 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)


rigr documentation built on Sept. 7, 2022, 1:05 a.m.