polyeval {tsdecomp} | R Documentation |
Polynomial Operations and Utilities
Description
Polynomial operations and utilities.
Usage
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 |
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 |
brackets |
logical, if |
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
Examples
# 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)