poly: Compute Polynomial fits of variables

View source: R/poly.R

polyR Documentation

Compute Polynomial fits of variables

Description

Compute Polynomial fits of variables for use in linear models.

Usage

poly(x, ..., degree = 1, raw = TRUE)

Arguments

x

Variable. The variable you would like to fit a polynomial to.

degree

Integer. The degree of the polynomial to fit.

raw

Logical. Defaults is TRUE, meaning the polynomial coefficient outputs can be used in direct calculations/predictions. Setting this value to FALSE results in orthogonal polynomials whose coefficients can't be used to compute predictions by hand.

Examples

# Use a quadratic polynomial to predict weight based on height.
lm(weight ~ poly(height, 2), data = cdc)


mobilizingcs/mobilizr documentation built on May 5, 2024, 1:01 a.m.