dwt                 package:waveslim                 R Documentation

_D_i_s_c_r_e_t_e _W_a_v_e_l_e_t _T_r_a_n_s_f_o_r_m (_D_W_T)

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

     This function performs a level J decomposition of the input vector
     or time series using the pyramid algorithm (Mallat 1989).

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

     dwt(x, wf="la8", n.levels=4, boundary="periodic")
     dwt.nondyadic(x)

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

       x: a vector or time series containing the data be to decomposed.
           This must be a dyadic length vector (power of 2).

      wf: Name of the wavelet filter to use in the decomposition.  By
          default this is set to '"la8"', the Daubechies orthonormal
          compactly supported wavelet of length L=8 (Daubechies, 1992),
          least asymmetric family.  

n.levels: Specifies the depth of the decomposition.  This must be a
          number less than or equal to log(length(x),2). 

boundary: Character string specifying the boundary condition.   If
          'boundary=="periodic"' the default, then the vector you
          decompose is assumed to be periodic on its defined interval,
           if 'boundary=="reflection"', the vector beyond its
          boundaries is assumed to be a symmetric reflection of itself. 

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

     The code implements the one-dimensional DWT using the pyramid
     algorithm (Mallat, 1989).  The actual transform is performed in C
     using pseudocode from Percival and Walden (2001).  That means
     convolutions, not inner products, are used to apply the wavelet
     filters.

     For a non-dyadic length vector or time series, 'dwt.nondyadic'
     pads with zeros, performs the orthonormal DWT on this dyadic
     length series and then truncates the wavelet coefficient vectors
     appropriately.

_V_a_l_u_e:

     Basically, a list with the following components 

      d?: Wavelet coefficient vectors.

      s?: Scaling coefficient vector.

 wavelet: Name of the wavelet filter used.

boundary: How the boundaries were handled.

_A_u_t_h_o_r(_s):

     B. Whitcher

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

     Daubechies, I. (1992) _Ten Lectures on Wavelets_, CBMS-NSF
     Regional Conference Series in Applied Mathematics, SIAM:
     Philadelphia.

     Gencay, R., F. Selcuk and B. Whitcher (2001) _An Introduction to
     Wavelets and Other Filtering Methods in Finance and Economics_,
     Academic Press.

     Mallat, S. G. (1989) A theory for multiresolution signal
     decomposition: the wavelet representation, _IEEE Transactions on
     Pattern Analysis and Machine Intelligence_, *11*, No. 7, 674-693.

     Percival, D. B. and A. T. Walden (2000) _Wavelet Methods for Time
     Series Analysis_, Cambridge University Press.

_S_e_e _A_l_s_o:

     'modwt', 'mra'.

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

     ## Figures 4.17 and 4.18 in Gencay, Selcuk and Whitcher (2001).
     data(ibm)     
     ibm.returns <- diff(log(ibm))
     ## Haar
     ibmr.haar <- dwt(ibm.returns, "haar")
     names(ibmr.haar) <- c("w1", "w2", "w3", "w4", "v4")
     ## plot partial Haar DWT for IBM data
     par(mfcol=c(6,1), pty="m", mar=c(5-2,4,4-2,2))
     plot.ts(ibm.returns, axes=FALSE, ylab="", main="(a)")
     for(i in 1:4)
       plot.ts(up.sample(ibmr.haar[[i]], 2^i), type="h", axes=FALSE,
               ylab=names(ibmr.haar)[i])
     plot.ts(up.sample(ibmr.haar$v4, 2^4), type="h", axes=FALSE,
             ylab=names(ibmr.haar)[5])
     axis(side=1, at=seq(0,368,by=23), 
          labels=c(0,"",46,"",92,"",138,"",184,"",230,"",276,"",322,"",368))
     ## LA(8)
     ibmr.la8 <- dwt(ibm.returns, "la8")
     names(ibmr.la8) <- c("w1", "w2", "w3", "w4", "v4")
     ## must shift LA(8) coefficients
     ibmr.la8$w1 <- c(ibmr.la8$w1[-c(1:2)], ibmr.la8$w1[1:2])
     ibmr.la8$w2 <- c(ibmr.la8$w2[-c(1:2)], ibmr.la8$w2[1:2])
     for(i in names(ibmr.la8)[3:4])
       ibmr.la8[[i]] <- c(ibmr.la8[[i]][-c(1:3)], ibmr.la8[[i]][1:3])
     ibmr.la8$v4 <- c(ibmr.la8$v4[-c(1:2)], ibmr.la8$v4[1:2])
     ## plot partial LA(8) DWT for IBM data
     par(mfcol=c(6,1), pty="m", mar=c(5-2,4,4-2,2))
     plot.ts(ibm.returns, axes=FALSE, ylab="", main="(b)")
     for(i in 1:4)
       plot.ts(up.sample(ibmr.la8[[i]], 2^i), type="h", axes=FALSE,
               ylab=names(ibmr.la8)[i])
     plot.ts(up.sample(ibmr.la8$v4, 2^4), type="h", axes=FALSE,
             ylab=names(ibmr.la8)[5])
     axis(side=1, at=seq(0,368,by=23), 
       labels=c(0,"",46,"",92,"",138,"",184,"",230,"",276,"",322,"",368))

