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