Should I decompose time series before applying DTW I have two time series which I want to compare by using the 'Dynamic Time Warping' technique. However, I am only interested in comparing the trend component of them (i.e. excluding the seasonal and random components from the comparison).
I wonder if it makes sense to perform an extra step in which I extract the trend component from the two time series before compare them together by using the dtw package in R, or I would get similar results by directly comparing the original time series via the dtw package.
 A: Yes, you should. Otherwise DTW will attempt to explain vaiblity that exists only in the y-axis, by spurious warping of the x-axis. This is explained in [a]
See also  https://www.cs.ucr.edu/~eamonn/sdm01.pdf
[a] https://www.cs.ucr.edu/~eamonn/sdm01.pdf
A: You are right to question this. Indeed if we are only interested in the trend component it makes more sense to focus on that. 
The reason is that random variation due to noise, seasonal trends, etc. will make the alignment task of the DTW more demanding and potentially result in misleading results. That is because the alignment of localised features might take precedence over the overall trends; the potential misalignment of peaks due to noise or external factors would induce substantial error accumulation. 
A standard time-series decomposition technique like STL by Cleveland et al. (1990) STL: A Seasonal-Trend Decomposition Procedure Based on Loess  (available in forecast::stl) is fine to start with but do consider other algorithms too like Ensemble Empirical Mode Decomposition (EEMD) from Wu and Huang Empirical Mode Decomposition: a Noise-Assisted Data Analysis Method 
 (available in Rlibeemd::eemd) or (X-13) Seasonal Extraction in ARIMA Time Series (SEATS) from Dagum and Bianconcini's (2016) "Seasonal Adjustment Based on ARIMA Model Decomposition: TRAMO-SEATS") (available in seasonal::seas).
