Initial Situation and Goal

Time series filtering (or smoothing) helps to reveal longer-term trends by smoothing noise and short-term fluctuations. The function in CornerstoneR implements four types of the moving average filter, namely:

  1. Simple: past values have the same weight;
  2. Exponential: assigns exponentially decreasing weights over time;
  3. Double-Exponential: applies the exponential filter twice, deals better with series that exhibit trends;
  4. Weighted: weighted average of past values.

Therefore, the user should choose a type of moving average and the window size of the smoothing. In the next steps, we will show an example of the Moving Average Filter in CornerstoneR.

Moving Average Filter

In this example, we will use the 'Trash' data set provided in Cornerstone as build-in Test Data. This data set contains 13 columns and 768 observations with details about the waste incineration in three different cities.

Trash data

Trash data

We select the menu 'Analyses' \(\rightarrow\) 'CornerstoneR' \(\rightarrow\) 'Moving Average Filter'.

Moving Average Filter: Menu

Moving Average Filter: Menu

In the appearing dialog, select the variable 'Time' as predictors, the variables 'Line Speed' and 'Feed Rate' as responses. We will select the variable 'City' for grouping in this example. If your data has no grouping, this field should be left blank. In case you want to include extra columns to your output dataset, you can put these to auxiliaries.

Moving Average Filter: Variable Selection

Moving Average Filter: Variable Selection

'OK' confirms your selection. The next step is to select the type of moving average and the window size. To do this, we open the menu 'R Script' \(\rightarrow\) 'Script Variables'. The screenshot shows the default options.

Moving Average Filter: R Script Variables Menu

Moving Average Filter: R Script Variables Menu

For this example we will use the default options. Close this dialog with 'OK' and click the execute button (green arrow) or choose the menu 'R Script' \(\rightarrow\) 'Execute' and all calculations are done via 'R'. Calculations are done if the text at the lower left status bar contains 'Last execute error state: OK'. Our results are available via the menus 'Summaries' and 'Graphs'.

The menu 'Data Filter' displays the original data, the smoothed responses and the remainder (true value minus the smoothed value).

Moving Average Filter: Data Filter

Moving Average Filter: Data Filter

In the menu 'Graphs', we can see one graph per group. Each graph contains all the responses variables that we selected in the beginning of the analysis ('Line Speed' and 'Feed Rate'). The graph 'Line Plot Data Filter for Group Des Moines' shows the original and smoothed values of the time series for the city Des Moines.

Moving Average Filter: Line Plot Data Filter for Group Des Moines

Moving Average Filter: Line Plot Data Filter for Group Des Moines