kza                   package:kza                   R Documentation

_K_o_l_m_o_g_o_r_o_v-_Z_u_r_b_e_n_k_o _A_d_a_p_t_i_v_e

_D_e_s_c_r_i_p_t_i_o_n:

     Detect change points in a time series.

_U_s_a_g_e:

     kza(v, q, k = 3)

_A_r_g_u_m_e_n_t_s:

       v: A vector of the time series

       q: The half length of the window size for the filter

       k: Number of iterations to run the filter, default = 3

_D_e_t_a_i_l_s:

     A change point is an abrupt change (change of structure due to
     economy, sociology, climate, legislation, etc.)  in the smooth
     baseline of the original data covered by noise. The KZA Algorithm
     can determine the unknown time  and value of that change. KZA can
     be used with missing values.

_R_e_f_e_r_e_n_c_e_s:

     I. Zurbenko, P.S. Porter, S.T. Rao, J.Y. Ku, R. Gui, R.E. Eskridge
     Detecting Discontinuities in Time Series of Upper-air Data:
     Development and Demonstration of an Adaptive Filter Technique.
     Journal of Climate: (1996) Vol. 9, No. 12, pp. 35483560. <URL:
     http://ams.allenpress.com/amsonline/?request=get-abstract&issn=152
     0-0442&volume=009&issue=12&page=3548>

     Kevin L. Civerolo, Elvira Brankov, S. T. Rao, Igor Zurbenko
     Assessing the impact of the acid deposition control program.
     Atmospheric Environment 35 (2001) 4135-4148 <URL:
     http://www.elsevier.com/locate/atmosenv>

_E_x_a_m_p_l_e_s:

     # period of sesonality is 365
     # initial parameter of kza 365

     # seasonal data
     yrs <- 20
     t <- seq(0,yrs,length=yrs*365)
     q <- 365/2

     #noise
     set.seed(6); e <- rnorm(n = length(t), sd = 1.0)
     trend <- seq(0,-1,length=length(t))

     #signal
     bkpt <- 3452
     brk <- c(rep(0,bkpt),rep(0.2,length(t)-bkpt))
     signal <- trend + brk

     # y = seasonal + trend + break point + noise
     y <- sin(2*pi*t) + signal + e

     # kza reconstruction of the signal
     z <- kza(y,q)
     k.kza <- z[[1]]

     # determine adaptive filter
     f <- kzf(y,q,rep(0,365*yrs))
     k.f <- f[[5]]

     # plot of sample variance
     s <- kzsv(k.kza,q,k.f)
     k.s <- s[[1]]

     par(mfrow=c(2,2))
     plot(y,type="l", main="Signal + Seasonality(365) + Noise ")
     plot(signal,type="l",ylim=c(-2,2), main="Signal and KZA Reconstruction (break=0.2,q=365/2)")
     lines(k.kza)
     plot(k.s,type="l",main="Sample Variance (break=0.2,q=365/2)")

     # example with break = 0.5
     brk <- c(rep(0,bkpt),rep(0.5,length(t)-bkpt))
     signal <- trend + brk

     # y = seasonal + trend + break point + noise
     y <- sin(2*pi*t) + signal + e

     # kza reconstruction of the signal
     z <- kza(y,365)
     k.kza <- z[[1]]
     plot(signal,type="l",ylim=c(-2,2), main="Signal and KZA Reconstruction (break=0.5,q=365)")
     lines(k.kza)

