# Autocorrelation and Seasonality in Time Series

**URL:** <https://forum.knime.com/t/autocorrelation-and-seasonality-in-time-series/75439>\
**Category:** KNIME Analytics Platform\
**Created:** [November 20, 2023, 7:19pm UTC](https://forum.knime.com/t/autocorrelation-and-seasonality-in-time-series/75439 "2023-11-20T19:19:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerius1st](https://forum-cdn.knime.com/user_avatar/forum.knime.com/rogerius1st/32/38975_2.png) [@rogerius1st](https://forum.knime.com/u/rogerius1st)\
**Post date:** [November 20, 2023, 7:19pm UTC](https://forum.knime.com/t/autocorrelation-and-seasonality-in-time-series/75439/1 "2023-11-20T19:19:08Z")

</div>

Dear Knimers,  
I have two time series (TS), which were uploaded here in the two CSV files (a) and (b):  
(a)  
[MA-SumExps-jan2017-jan2020.csv](https://forum.knime.com/uploads/short-url/skxd5Pf821XgHDM1mubhTmyb5M0.csv) (1.1 KB)  
(b)  
[MA-SumExps-mai2020-jun2023.csv](https://forum.knime.com/uploads/short-url/2Z7M3nug5fYbCi5nAjCHEjg08Az.csv) (1.2 KB)  
Indeed, it is a matter of Interrupted Time Series (ITS), as can be deduced from their file names.  
I need to demonstrate that the differences in both trends are statistically significant. The angular coefficient of the second is 4.75 times higher than the first.  
Before splitting the original TS into two parts, I got the following graph (for the whole period):

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/d/9d74860ce54c26a4f7a76c17999cd94e0c27c5e5.png)  
And after splitting it, I got these two graphs:

1. for the period “pre-COVID”  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/a/c/ac6c89ae9c591436da711d71d32d5c558f2fc842.png)
2. for the period “post-COVID onset”  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/3/93be6d2d1beb7fa78aed9ae584d3d666992855f1.png)

I ask for your help with some tasks:

1. to (separately) investigate if there is autocorrelation in each TS; and
2. to inspect (and if possible, to remove) the seasonality in these two series, but without using resources (e.g., with Knime “Components”) that require Python or R installation.  
Can someone help me to accomplish both tasks?

Thanks for all the help received.  
B.R.,  
Rogério.

---

<div class="post-metadata">

**Author:** ![AlexanderFillbrunn](https://forum-cdn.knime.com/user_avatar/forum.knime.com/alexanderfillbrunn/32/357_2.png) [@AlexanderFillbrunn](https://forum.knime.com/u/AlexanderFillbrunn)\
**Post date:** [November 21, 2023, 8:45am UTC](https://forum.knime.com/t/autocorrelation-and-seasonality-in-time-series/75439/2 "2023-11-21T08:45:31Z")

</div>

Hi,  
For the auto-correlation, you could use the [Lag Column](https://kni.me/n/RurwVi1VODgLDTQP) node to lag values and then calculate the auto-correlation with [Math Formula](https://kni.me/n/2fI5rIsFDCFPHc0R) node for the inner terms and [GroupBy](https://kni.me/n/5stmXk6zY_ORA4bC) with sum aggregation for the sums based on the formulas given [here](https://stats.stackexchange.com/questions/493807/how-to-calculate-the-acf-and-pacf-for-time-series).  
For the seasonality, you could simply calculate the difference between each value and the value 12 months before, again using the Lag Column node with a lag interval of 12 and a Math Formula node for the calculation. Make sure to subtract the trend from your data before doing the seasonality removal, then add the trend again. For that you can add a new column “x” that is simply the row index, then train a linear regression on the data and apply a [Regression Predictor](https://kni.me/n/LyRcLydCVnHBRIb0) to the same data. Then use Math Formula to calculate the difference between your value and the predicted value.  
Kind regards,  
Alexander

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [February 19, 2024, 8:45am UTC](https://forum.knime.com/t/autocorrelation-and-seasonality-in-time-series/75439/3 "2024-02-19T08:45:59Z")

</div>

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