I have multiple time-series of length 149 and I would like to denoise them by using wavelet transformations.
This is an example of my data:
t=ts(rnorm(149,5000,1000),start=1065,end=1213)
When I try using the packages wavetresh and waveslim, they both point me to the same problem:
library(wavetresh)
wd(t)
Error in wd(t) : Data length is not power of two
library(waveslim)
dwt(t)
Error in dwt(t) : Sample size is not divisible by 2^J
I understand that my data length should be of lenght 2^x, but I can't overcome this problem. I thought the function up.sample()
in waveslim was supposed to help with this, but it didn't do the trick (e.g. up.sample(t,2^8)
gives a vector of length 38144). So how do I increase my vector length without inserting an error? I know I could pad with zero's,... but I want to know the best way to do this.
Also, when looking at the example of waveslim, it looks as if the length of the imput serie doesn't fulfill this requirement either (although the example of course does work):
data(ibm)
ibm.returns <- diff(log(ibm))
ibmr.haar <- dwt(ibm.returns, "haar") #works
log2(length(ibm.returns))
[1] 8.523562
I feel like I'm missing something basic, but I can't figure it out. Thanks for any help.
Ps: I know I can use other techniques to do this, but I really want to test this approach.