[R] wavethresh: length must be power of two

Oscar Perpiñan Lamigueiro oscar.perpinan at upm.es
Tue Mar 9 12:00:43 CET 2010


I am using the 4.2 version of the wavethresh package available from here: http://www.stats.bris.ac.uk/~wavethresh/ trying to follow the book of Nason (http://www.springer.com/978-0-387-75960-9). 

I am interested in the analysis of several years time series of daily data with wavelets methods. But the functions of this package only accept data whose lengths are power of two, even for non-decimated DWT. 

For example:

> data=rnorm(365)
> wdS <- wd(data, type="station")
Error en wd(data, type = "station") : Data length is not power of two

A possible solution is to analyse a window with a length power of two. For this example:

> data2=data[1:(2^trunc(log(365,2)))]
> wdS2 <- wd(data2, type="station")

or pad with zeros:

> data3=data
> length(data3)<-2^ceiling(log(length(data),2))
> data3[is.na(data3)]<-0
> wdS3<-wd(data3,type='station')

Is there any other solution?

By the way, does anybody knows why the wavethresh package at CRAN is not being updated?

Thank you very much!

Oscar Perpiñán Lamigueiro
Department of Electrical Engineering
Universidad Politécnica de Madrid

More information about the R-help mailing list