get_polynomial_function: Function factory to create polynomial functions

View source: R/PolyMRDataSim_polynomial_function.R

get_polynomial_functionR Documentation

Function factory to create polynomial functions

Description

This function factory is intended for use with the PolyMRDataSim class. It simplifies the creation of polynomial functions based on its coefficients.

Usage

get_polynomial_function(polynomial_coefficients = c(0.1))

Arguments

polynomial_coefficients

A vector of coefficients for the polynomial terms, in ascending order of degree (default is c(0.1)). The length of the vector determines the degree of the resulting polynomial.

Value

A polynomial function with the corresponding coefficients.

Examples

  cubic_polynomial <- get_polynomial_function(c(0.5, 0, 2))

  some_values <- rnorm(100)
  all(cubic_polynomial(some_values) == 0.5*some_values + 2*some_values^3)


JonSulc/PolyMR documentation built on April 26, 2023, 10:42 a.m.