Learn R Programming

kza (version 2.03)

kz_decompose: Kolmogorov-Zurbenko decompose

Description

Kolmogorov-Zurbenko decomposition of univariate time series into long term and seasonal components.

Usage

kz_decompose(y, k=3, period=NULL)
## S3 method for class 'kzd':
fitted(object, \dots)
## S3 method for class 'kzd':
residuals(object, \dots)
## S3 method for class 'kzd':
trend(object, \dots)
## S3 method for class 'kzd':
frequency(x, \dots)
## S3 method for class 'kzd':
predict(object, n.ahead = 1, prediction.interval = FALSE, level = 0.95, \dots)
## S3 method for class 'kzd':
plot(x, main = paste("KZ Decomposition of time series"), ...)
## S3 method for class 'kzd':
summary(object, digits=getOption("digits"), ...)

Arguments

y
univariate time series.
k
Number of iterations.
period
Vector with the window sizes for the long term and seasonal period.
object
kzd object returned from kz_decompose.
x
kzd object returned from kz_decompose.
...
Other parameters.
n.ahead
The number of data points ahead to predict.
prediction.interval
prediction interval level
level
level
digits
precision
main
Plot title.

Details

KZ is an iterated moving average filter.

Examples

Run this code
yrs <- 20
t <- seq(0,yrs,length=yrs*365)
amp<-10
y <- amp*sin(2*pi*t*12+10)
y<-ts(y,start=c(1980,10),frequency=365)
signal<-y

tr<-seq(1, amp/2, length.out=7300)
y.orig<-signal+exp(tr)+300
y<-y.orig
set.seed(6); e <- rnorm(n = length(t), sd = 50)
SNR<-mean(abs(y)^2)/(mean((abs(e)^2)))
y<-log(y+e)

a<-kz_decompose(y, period=c(365,30))
plot(a)

Run the code above in your browser using DataLab