vignettes/autocorrelation.Rmd
autocorrelation.Rmd
In many cases, the autocorrelation and partial autocorrelation are good indicators for helping to choose time series models.
In this Demo we use ‘trash’ sample data from the Cornerstone build-in TestData, which contains details about the waste incineration in three different cities. Here, we take a subset from the original dataset and only analyze the first city ‘Des Moines’.
Trash Data
After grouping the data by day, we retrieve the following dataset,
which is a clean dataset with equally distanced timestamps.
To calculate ACF (autocorrelation), PACF (partial autocorrelation) and CCF (cross-correlation) choose menu ‘Analyses’ -> ‘CornerstoneR’ -> ‘Autocorrelation’ as shown in the following screenshot.
Autocorrelation: Menu
In the appearing dialog select the variables as in the screenshot. The cross-correlation will be computed between the predictors and responses.
Autocorrelation: Variable Selection
‘OK’ confirms your selection and the following window appears.
Autocorrelation: R Script
open the menu ‘R Script’ \(\rightarrow\) ‘Script Variables’. You can customize:
we will use the script variables as in the screenshot of this example.
Autocorrelation: R Script Variables Menu
Now 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’ as shown in the following screenshot.
open the ‘Lag table for Mean Line Speed’, you can see the values are shifted down according to predefined lags.
Autocorrelation: Lag Table
Open the ‘Autocorrelation summary’, you get the autocorrelation for
each variable and its different lags summarized in one table.
Open the ‘Partial autocorrelation summary’, you get the partial
autocorrelation for each variable and its different lags summarized in
one table.
Open the ‘Cross correlation summary’, you get all the
cross-correlations between predictors and responses for different lags.
By opening the following plots under ‘Graphs’:
you can see the corresponding plots, where the blue dotted line shows the 90% confidence interval as of the confidence level we set earlier within the script variables.
The final workmap looks as shown in the following screenshot.