eval_poly: Polynomial evaluation

View source: R/eval_poly.R

eval_polyR Documentation

Polynomial evaluation

Description

Evaluates one or several polynomials on the given data.

Usage

eval_poly(poly, newdata)

Arguments

poly

List containing 2 items: labels and values.

  • labels: List of integer vectors with same length (or number of cols) as values, where each integer vector denotes the combination of variables associated to the coefficient value stored at the same position in values. That is, the monomials in the polynomial. Note that the variables are numbered from 1 to p, with the intercept is represented by 0.

  • values: Matrix (can also be a vector if single polynomial), where each column represents a polynomial, with same number of rows as the length of labels, containing at each row the value of the coefficient of the monomial given by the equivalent label in that same position.

Example: If labels contains the integer vector c(1,1,3) at position 5, then the value stored in values at row 5 is the coefficient associated with the term x_1^2*x_3.

newdata

Input data as matrix, vector or dataframe. Number of columns (or elements in vector) should be the number of variables in the polynomial (dimension p). Response variable to be predicted should not be included.

Details

Note that this function is unstable and subject to change. Therefore it is not exported but this documentations is left available so users can use it if needed to simulate data by using nn2poly:::eval_poly()

Value

Returns a matrix containing the evaluation of the polynomials. Each column corresponds to each polynomial used and each row to each observation, meaning that each column vector corresponds to the results of evaluating all the given data for each polynomial.

See Also

eval_poly() is also used in predict.nn2poly().


nn2poly documentation built on May 29, 2024, 5:08 a.m.