pct function

Percentage Change Transformation

Percentage Change Transformation

The pct() function returns a transformation of the provided time series using a Percentage Change transformation. pct.rev() reverses the transformation.

pct(x) pct.rev(p, xi, addinit = TRUE)

Arguments

  • x: A numeric vector or univariate time series of class ts.
  • p: A numeric vector or univariate time series of percentage changes. Possibly returned by pct().
  • xi: Initial value/observation of x (x[1]). First known non-transformed value used to recursively obtain the original series.
  • addinit: If TRUE, xi is included in the return.

Returns

A vector of length length(x)-1 containing the transformed values.

Details

The Percentage Change transformation is given approximately by

log(x[2:n]/x[1:(n1)])=log(x[2:n])log(x[1:(n1)]) log(x[2:n] / x[1:(n-1)] ) = log( x[2:n] ) - log( x[1:(n-1)] )

where n=length(x).

Examples

data(NN5.A) ts <- na.omit(NN5.A[,10]) length(ts) p <- pct(ts) length(p) p_rev <- pct.rev(p, attributes(p)$xi) all(round(p_rev,4)==round(ts,4))

References

R.H. Shumway and D.S. Stoffer, 2010, Time Series Analysis and Its Applications: With R Examples. 3rd ed. 2011 edition ed. New York, Springer.

See Also

Other transformation methods: Diff(), LogT(), WaveletT(), emd(), mas(), mlm_io(), outliers_bp(), train_test_subset()

Author(s)

Rebecca Pontes Salles

  • Maintainer: Rebecca Pontes Salles
  • License: GPL (>= 2)
  • Last published: 2021-01-21