# Time Series Forecasting with differenced series

**URL:** <https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152>\
**Category:** KNIME Analytics Platform\
**Tags:** time-series\
**Created:** [April 27, 2022, 6:07am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152 "2022-04-27T06:07:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franziska\_W](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Franziska\_W](https://forum.knime.com/u/Franziska_W)\
**Post date:** [April 27, 2022, 6:07am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/1 "2022-04-27T06:07:04Z")

</div>

Hello,

how can I get the original values back from a forecasted differenced time series? The picture below shows my original series (Original GDP), the lagged column and finally the differenced column. I used the differenced column to forecast 2001 - 2003. The results from the forecast are shown in column E. To get the original values I used the last available original value (2000Q4) plus the forecast. But afterwards I need the “Forecasted Original” previous value to calculate the next original value. Is there any possibility to do this easily in KNIME?

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/5/5/55c86b82fe2e7f78554111f794b4bee1ae58ad0d.png)

Any help would be much appreciated.  
Thank you in advance,  
Franziska

---

<div class="post-metadata">

**Author:** ![gonhaddock](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gonhaddock/32/35425_2.png) [@gonhaddock](https://forum.knime.com/u/gonhaddock)\
**Post date:** [April 27, 2022, 7:00am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/2 "2022-04-27T07:00:44Z")

</div>

Hello @Franziska_W

You can use the [Lag Column](https://nodepit.com/node/org.knime.base.node.preproc.columnlag.LagColumnNodeFactory) node to get a row+1 $Forecasted Original$ column, then calculate the difference has to be quite straight forward.

BR

---

<div class="post-metadata">

**Author:** ![Franziska\_W](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Franziska\_W](https://forum.knime.com/u/Franziska_W)\
**Post date:** [April 27, 2022, 7:15am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/3 "2022-04-27T07:15:12Z")

</div>

Hello @gonhaddock

Thank you for your fast reply!  
I was already thinking of that but I don’t really understand how the Lag Column can help.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/0/2/0206df1ec9f08836fe1354d7f77d12a41af5ff1c.png)

The first row I can simply calculate (11,334.544 + 99.704). Then I used Lag 1 and now I can calculate row 2 (11,434.248 + 78.397). But afterwards I need apply the Lag 1 again and this is very time-consuming. Am I missing something here?

Thank you.  
BR  
Franziska

---

<div class="post-metadata">

**Author:** ![gonhaddock](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gonhaddock/32/35425_2.png) [@gonhaddock](https://forum.knime.com/u/gonhaddock)\
**Post date:** [April 27, 2022, 7:57am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/4 "2022-04-27T07:57:58Z")

</div>

I see, your solution is a ‘Recursive Loop’ as you have to assign the result of the calculation as part of the calculation for the next row.

I can try to built an example workflow as the configuration isn’t simple. Can take me some time.

BR

---

<div class="post-metadata">

**Author:** ![Franziska\_W](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Franziska\_W](https://forum.knime.com/u/Franziska_W)\
**Post date:** [April 27, 2022, 8:15am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/5 "2022-04-27T08:15:06Z")

</div>

That would be really great! Thank you in advance!

BR  
Franziska

---

<div class="post-metadata">

**Author:** ![gonhaddock](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gonhaddock/32/35425_2.png) [@gonhaddock](https://forum.knime.com/u/gonhaddock)\
**Post date:** [April 27, 2022, 9:34am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/6 "2022-04-27T09:34:20Z")

</div>

Hi @Franziska_W

Maybe the solution looks a bit complex, and in fact it is. Should be easier to code it in a script node with R or Py; however it is a good exercise to have in KNIME Hub

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/4/e449a22f8e0e7b4810e23197ca0ed376ec3ab339.png)

> **[Data Wrangling \_ Recursive Equation – gonhaddock](https://hub.knime.com/gonhaddock/spaces/Public/latest/Data%20Wrangling%20_%20Recursive%20Equation~SR3A7xqxX0dAjCHr)**
>
> Workflow created for the KNIME forum ... https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152 DESCRIPTION: The challenge ... For any…

You will notice some decimal differences from CHALLENGE result to TARGET column, but I just worked with the 3 decimals displayed in your picture.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/3/b/3b4c4c45970317146dec18a6d5a2888ab0c60501.jpeg)

I think that it should fit with your needs.

BR

---

<div class="post-metadata">

**Author:** ![Franziska\_W](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Franziska\_W](https://forum.knime.com/u/Franziska_W)\
**Post date:** [April 27, 2022, 10:52am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/7 "2022-04-27T10:52:03Z")

</div>

This worked - thank you so much @gonhaddock !

BR  
Franziska

---

<div class="post-metadata">

**Author:** ![Daniel\_Weikert](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@Daniel\_Weikert](https://forum.knime.com/u/Daniel_Weikert)\
**Post date:** [April 27, 2022, 6:25pm UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/8 "2022-04-27T18:25:11Z")

</div>

Column Expression with Moving Agg should also work

 ![mv](https://forum-cdn.knime.com/uploads/default/original/3X/c/c/cc930e14584e8956459f563407be84a8ed272bb1.png)

br

---

<div class="post-metadata">

**Author:** ![gonhaddock](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gonhaddock/32/35425_2.png) [@gonhaddock](https://forum.knime.com/u/gonhaddock)\
**Post date:** [April 27, 2022, 7:20pm UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/9 "2022-04-27T19:20:20Z")

</div>

kudos @Daniel_Weikert  
I didn’t even thought about this approach.

---

<div class="post-metadata">

**Author:** ![Daniel\_Weikert](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@Daniel\_Weikert](https://forum.knime.com/u/Daniel_Weikert)\
**Post date:** [April 28, 2022, 6:55pm UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/10 "2022-04-28T18:55:11Z")

</div>

Thanks @gonhaddock  
“I didn’t even thought about this approach.” That’s what I think each day I see a new well designed solution in this forum. The community here is really unique. Thanks to you and others people can really find help here.  
Thanks for your contribution.  
br and take care

---

<div class="post-metadata">

**Author:** ![Franziska\_W](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Franziska\_W](https://forum.knime.com/u/Franziska_W)\
**Post date:** [April 29, 2022, 5:01am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/11 "2022-04-29T05:01:22Z")

</div>

@Daniel_Weikert  
also thank you for your approach!  
I can totally agree with you that this community is really great.

BR  
Franziska

---

<div class="post-metadata">

**Author:** ![gonhaddock](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gonhaddock/32/35425_2.png) [@gonhaddock](https://forum.knime.com/u/gonhaddock)\
**Post date:** [April 29, 2022, 11:27am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/12 "2022-04-29T11:27:51Z")

</div>

Hi,  
Maybe I was biased in this solution. I used this WF before for a much more complex [forum topic](https://forum.knime.com/t/how-to-create-a-loop-between-to-equations-using-ones-input-as-the-others-output/39741) ; that solution addressed a very complex case, with an unsolved data gathering, and double equation system for many items, implemented with a nested ‘Recursive Loop’ .

As summary, I saw a good opportunity to clean-up the workflow with this simple equation. Now, the complex part to configure the Recursive Loop is clean, and it can be scaled up for a more complex problems. And besides that, it is always a good fun to participate.

BR

---

<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:** [May 6, 2022, 11:27am UTC](https://forum.knime.com/t/time-series-forecasting-with-differenced-series/42152/13 "2022-05-06T11:27:52Z")

</div>

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