# Time-series decomposition to a base level and an effect of another feature

I've got a time-series data (let's denote it as y) and some feature (let's denote it as x). y is dependent on x, but x is often equal to 0. Even then, y is not 0, so we can assume that there's a base level in y which is independent of x. Additionally, we can observe some seasonality in y. I need to decompose y into base level and an effect of x. And I need some hint about methodology. I have googled and found plenty of methods to decompose time-series data into trend, seasonality and random noise. However, my case is different, because I have an additional feature x and I would like just to extract its effect, and leave trend, seasonality and noise alltogether. What I have in mind can be represented on a plot below, where turquoise area represents base level of y and red area represents an effect of x. What method would allow to make such a split? I would also appreciate any links or materials.

• The Residual RNN could be relevant, but you need to modify a bit. The idea is to use a linear model (i.e. ARIMA or KF) to predict y based on history of y, and use a RNN to model the residual errors (predicted_y - y). – user12075 Sep 8 '18 at 18:11
• Another thing to think about. If x has trend/seasonality, and x influences y to have a similar trend/seasonality, would you define that part of variance in y as "effects of x", or "y's seasonality"? You may want to do an ANOVA test between x and the residual errors (predicted_y - y) to see whether x affects y besides y's own trend/seasonality. – user12075 Sep 8 '18 at 18:16

I would use some form of seasonal time series model that accepts external regressors, like auto.arima from forecast in R. There's a nice example from Rob Hyndman here. Likely any method you use will decompose the series into seasonal, trend, level and residual in addition to the contribution of the external regressor, but it is easy enough to re-combine everything except the external regressor to achieve the plot you're after.