poly-operations: Polynomial Operations and Utilities

Description Usage Arguments Details Note See Also Examples

Description

Polynomial operations and utilities.

Usage

1
2
3
4
5
polystring(x, varchar = "x", brackets = FALSE, ndec = 2, emptychar = "")
polyeval(p, x)
polyprod(x, y, tol = 1.490116e-08) 
polydiv(x, y)
roots2poly(x)

Arguments

x

numeric vector containing the coefficients of the polynomial (in increasing order and without gaps). For polyeval, this is the point at which the polynomial is to be evaluated. For roots2poly, this is a numeric vector containing the roots of the polynomial.

y

numeric vector containing the coefficients of the polynomial (in increasing order and without gaps).

p

numeric vector containing the coefficients of the polynomial (in increasing order and without gaps).

varchar

character string, the label to be printed representing the variable of the polynomial, defaults to "x".

brackets

logical, if TRUE the polynomial is printed within parentheses.

ndec

integer, coefficients are rounded up to this number of decimals.

emptychar

the character string to be printed if the polynomial is empty.

tol

a numeric, tolerance below which coefficients are set to zero.

Details

polystring returns a string of a numeric vector in the format of a polynomial.

polyeval evaluates the polynomial defined in the vector of coefficients p at the point x.

polyprod performs polynomial multiplication.

polydiv performs polynomial division (returning the quotient and the remainder).

roots2poly computes the coefficients of a polynomial from its roots.

Note

polyprod is based on convolve; it is equivalent to convolve(x, rev(y), type="open").

roots2poly is based on poly.from.zeros() in package polynom.

See Also

polyroot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# print a fitted ARMA model
set.seed(123)
y <- arima.sim(n=120, model=list(ar=c(0.8, -0.3), ma=0.6))
fit <- arima(y, order=c(2,0,1), include.mean=FALSE)
cat(paste0(
polystring(c(1, -fit$model$phi), brackets=TRUE, ndec=3), "y_t = ",
polystring(c(1, fit$model$theta), brackets=TRUE, ndec=3), "e_t\n"))

# convert roots to coefficients
p <- c(1, 0.8, -0.3)
cat(polystring(p))
r <- polyroot(p)
roots2poly(r)

tsdecomp documentation built on May 1, 2019, 9:15 p.m.