Poly: Polynomial Matrix

View source: R/general.R

PolyR Documentation

Polynomial Matrix

Description

A modified 'poly()' function that allows for missing values.

Usage

Poly(x, degree = 1, coefs = NULL, raw = FALSE, ...)

Arguments

x

variable to convert to matrix

degree

degree of polynomial

coefs

pass to poly() function

raw

pass to poly() function

...

more arguments for the poly() function

Details

Credit goes to whoever posted this online first (google search if you must find it!)

Value

a matrix, with NAs in the missing rows

Author(s)

Tom Elliott

Examples

Poly(rnorm(100), degree = 2L)

# handles missing values:
iris.na <- iris
iris.na$Sepal.Length[c(5, 10)] <- NA
lm(Sepal.Width ~ Poly(Sepal.Length, 2L), data = iris.na)

# stats::poly() produces an error in this case:
# lm(Sepal.Width ~ poly(Sepal.Length, 2L), data = iris.na)


iNZightVIT/iNZightRegression documentation built on April 8, 2024, 10:25 a.m.