data decomposition using dwt

Here is the code for using discrete wavelet transformation for data preprocessing by decomposing the input vector and use it for linear regression to predict ames housing sale prices

library(wavelets)
library(waveslim)
library(AmesHousing)

ames <- as.data.frame(AmesHousing::make_ames())
x <- subset(ames, select = -Sale_Price)
y <- ames$Sale_Price
dwt(x)

An error pops up

x <- dwt(x)
Error in dwt(x) : 'list' object cannot be coerced to type 'double'

Hello guys, please I need help with this

waveslim::dwt() expects a time series. It looks like you are trying to pass in a list.

https://www.rdocumentation.org/packages/waveslim/versions/1.12/topics/dwt

It says in the documentation as I quote x is

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

Therefore I thought x is a vector that can be decomposed.

dwt() is used for time series data. Ames isn't a time series.

dwt {waveslim} R Documentation
Discrete Wavelet Transform (DWT)
Description
This function performs a level J decomposition of the input vector or time series using the pyramid algorithm (Mallat 1989).

Your x object is a full dataset.

Look at the example:

## 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")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.