0
$\begingroup$

I did a time series decomposition on a series of Twitter activity data into trend, seasonal and residual component. I checked the distribution of the residuals when fitting a linear model to the time series and came to the conclusion that they are not normally distributed and I therefore have to assume heteroskedasticity (it was also shown by a low p-value in Breusch-Pagan test) of the data which implies that I need to do the decomposition based on a multiplicative assumption.

To do the decomposition I use python statsmodels.tsa.seasonal import MSTL. This model always assumes additivity of data so I applied a log transformation in order to equalise the variance of my data. Since I have a lot of zero values in the dataset I use log(x+1) for the transformation.

So after the decomposition in order to get back to my original signal I need to back transform the data, by the following:

original_signal = exp(trend+seasonal+residuals)-1

This works and gives me exactly my original signal. However since I want to continue working only on the residuals I want to back transform the individual components as well. Ho can I do this, I assumed it is similarly just:

  1. trend = exp(trend_transformed) - 1
  2. seasonal = exp(seasonal_transformed) - 1
  3. residual = exp(residual_transformed) - 1

But if this is the right way - how are these individual components related to the original time series signal. It is obviously not by addition or multiplication.

I hope I am not overseeing something and asking a very stupid questions.

$\endgroup$
2
  • 2
    $\begingroup$ Could you explain why "continue working on the residuals" implies any need to back-transform them? As a side note concerning your choice of transformation, you might find our threads at stats.stackexchange.com/questions/41361 and stats.stackexchange.com/questions/30728 to be useful (among others on this subject). $\endgroup$
    – whuber
    Aug 29, 2023 at 20:26
  • 1
    $\begingroup$ Thanks for the reply - to be honest I do not have a good answer on the question. I want to do correlation analysis with the residuals and might even use log transformation for this. In general I just had the feeling that I want to get the data as closest as possible to the original after the decomposition. But even if the back-transformation is not necessary, I would be interested in understanding how to generally do it. Thanks also for the threads in how to choose c. I took 1 because my 0 values are actual 0 values (no one tweeted at this time on the given topic). $\endgroup$
    – Mim_Tauch
    Aug 29, 2023 at 20:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.