Search code examples
rwavelet

wavelet package Inverse DWT fails to reconstruct series?


I'm using the wavelets package, and noticed that when I try

library("wavelets")
x <- rnorm(100)
y <- idwt(dwt(x))
plot(x, y)

the reconstruction y is apparently not equal to the original x.

Is this to be expected?

For some context, I'm trying to do a (regularized) logistic regression using the wavelet transforms of a bunch of series. I then want to map the regression coefficient back into the original time series space, to see which time points were used in the discrimination.

But I can't seem to even reconstruct the original series. I might be completely misunderstanding things, can anyone shed some light on this?


Solution

  • Following the help file ?dwt, you can modify your script, such as:

    library(wavelets)
    set.seed(42)
    x <- rnorm(100)
    y <- idwt(dwt(x, n.levels=3, boundary="reflection", fast=FALSE))
    plot(x, y)
    abline(0,1)
    

    enter image description here