19 Time Series Analysis
Instructions to create a time plot
- Use a dataset in your Rguroo account or recreate the example below by importing the AirPassengers dataset from the Rguroo dataset repository called R Datasets into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Click on the
Analysis
dropdown menu and choose the Time Series function (see Figure 19.1).Select your dataset from the Dataset dropdown menu. In this example, we select the AirPassengers dataset.
From the Numerical Variables section, select and drag the variable AirPassengers to the
Selected
column.(Optional) Under the Time Specification section, from the Type dropdown, select the time frequency of your data (yearly, quarterly, monthly, daily, hourly, by minute or seconds). The AirPassengers data are monthly, so we select Month from the Type dropdown menu. Then set an appropriate start month and year for the data. The AirPassengers data starts from January 1949, so set
Year
to \(\tt{1949}\) andMonth
to \(\tt{1}\).In the section Time Series Plot, select the Lines checkbox and optionally the Points checkbox.
Click the Preview icon to view the graph.
- Use a dataset in your Rguroo account or recreate the example below by importing the AirPassengers dataset from the Rguroo dataset repository called R Datasets into your account (see Figure 19.2).
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Click on the
Analysis
dropdown menu and choose the Time Series function.Select your dataset from the Dataset dropdown menu. In this example, we select the AirPassengers dataset.
From the Numerical Variables section, select and drag the variable AirPassengers to the
Selected
column.(Optional) Under the Time Specification section, from the Type dropdown, select the time frequency of your data (yearly, quarterly, monthly, daily, hourly, by minute or seconds). The AirPassengers data are monthly, so we select Month from the Type dropdown menu. Then set an appropriate start month and year for the data. The AirPassengers data starts from January 1949, so set
Year
to \(\tt{1949}\) andMonth
to \(\tt{1}\).In the section Time Series Plot, select the Lines and Moving Average checkbox.
In the text field to the right of Moving-Average labeled q-Param, enter an integer value equal to the desired number of periods to calculate the moving average over.
Click the Preview icon to view the graph.
Instructions to create an exponential smoothing plot in Rguroo
- Use a dataset in your Rguroo account or recreate the example below by importing the USAccDeaths dataset from the Rguroo dataset repository called R Datasets into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Click on the
Analysis
dropdown menu and choose the Time Series function (see Figure 19.3) .Select your dataset from the Dataset dropdown menu. In this example, we select the USAccDeaths dataset.
From the Numerical Variables section, select and drag the variable USAccDeaths to the
Selected
column.(Optional) Under the Time Specification section, from the Type dropdown, select the time frequency of your data (yearly, quarterly, monthly, daily, hourly, by minute or seconds). The USAccDeaths data are monthly, so we select Month from the Type dropdown menu. Then set an appropriate start month and year for the data. The USAccDeaths data starts from January 1, 1973 so set
Year
to \(\tt{1973}\) andMonth
to \(\tt{1}\).Click on the button to open the modeling dialog.
In the Methods and Forecasting dialog under the Method section, check Exponential and Graph.
In the text field to the right of Exponential, optionally enter an Alpha value between 0 and 1. If a value is not specified, a default value will be chosen by Rguroo. We use a value of 0.5 for Alpha in this example.
Click the Preview icon to view the graph.
Instructions for exponential smoothing in Rguroo
- Use a dataset in your Rguroo account or recreate the example below by importing the USAccDeaths dataset from the Rguroo dataset repository called R Datasets into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Click on the
Analysis
dropdown menu and choose the Time Series function (see Figure 19.4) .Select your dataset from the Dataset dropdown menu. In this example, we select the USAccDeaths dataset.
From the Numerical Variables section, select and drag the variable USAccDeaths to the
Selected
column.(Optional) Under the Time Specification section, from the Type dropdown, select the time frequency of your data (yearly, quarterly, monthly, daily, hourly, by minute or seconds). The USAccDeaths data are monthly, so we select Month from the Type dropdown menu. Then set an appropriate start month and year for the data. The USAccDeaths data starts from January 1, 1973 so set
Year
to \(\tt{1973}\) andMonth
to \(\tt{1}\).Click on the button to open the modeling dialog.
In the Methods and Forecasting dialog under the Method section, check Double Exponential and Graph.
In the text field to the right of Double Exponential, optionally enter an Alpha and/or a Beta value between 0 and 1. If a value is not specified, a default value will be chosen by Rguroo. We use a value of 0.5 for Alpha and 0.3 for Beta are used for this example.
Click the Preview icon to view the graph.
Instructions for Holt-Winters in Rguroo
- Use a dataset in your Rguroo account or recreate the example below by importing the AirPassengers dataset from the Rguroo dataset repository called R Datasets into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Click on the
Analysis
dropdown menu and choose the Time Series function (see Figure 19.5) .Select your dataset from the Dataset dropdown menu. In this example, we select the AirPassengers dataset.
From the Numerical Variables section, select and drag the variable AirPassengers to the
Selected
column.Under the Time Specification section
- In the text field next to Freq., enter an integer value greater than or equal to 2 representing the number of observations per unit of time (4 for quarterly data, 12 for monthly data, etc.). A Freq. value of 12 is used for this example.
- (Optional) From the Type dropdown, select the time frequency of your data (yearly, quarterly, monthly, daily, hourly, by minute or seconds). The AirPassengers data are monthly, so we select Month from the Type dropdown menu. Then set an appropriate start month and year for the data. The AirPassengers data starts from January 1, 1949 so set
Year
to \(\tt{1949}\) andMonth
to \(\tt{1}\).
Click on the button to open the modeling dialog.
In the Methods and Forecasting dialog under the Method section, check Holt-Winters’ and select the Graph checkbox.
In the text field to the right of Double Exponential, optionally enter an Alpha, Beta, and/or Gamma value between 0 and 1. If a value is not specified, a default value will be chosen by Rguroo. In this example we use Rguroo’s default values.
In the dropdown menu labeled Holt-Winters’ Model Type select one of Additive or Multiplicative for the type of seasonal smoothing. We select Additive for this example.
Click the Preview icon to view the graph.
Instructions for classical decomposition in Rguroo
- Use a dataset in your Rguroo account or recreate the example below by importing the AirPassengers dataset from the Rguroo dataset repository called R Datasets into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Click on the
Analysis
dropdown menu and choose the Time Series function (see Figure 19.6).Select your dataset from the Dataset dropdown menu. In this example, we select the AirPassengers dataset.
From the Numerical Variables section, select and drag the variable AirPassengers to the
Selected
column.Under the Time Specification section
- In the text field next to Freq., enter an integer value greater than or equal to 2 representing the number of observations per unit of time (4 for quarterly data, 12 for monthly data, etc.). A Freq. value of 12 is used for this example.
- (Optional) From the Type dropdown, select the time frequency of your data (yearly, quarterly, monthly, daily, hourly, by minute or seconds). The AirPassengers data are monthly, so we select Month from the Type dropdown menu. Then set an appropriate start month and year for the data. The AirPassengers data starts from January 1, 1949 so set
Year
to \(\tt{1949}\) andMonth
to \(\tt{1}\).
At the bottom of the dialog, select Classical Decomposition Graph.
From the Model Type dropdown menu to the right of the Classical Decomposition Graph checkbox, select one of Additive or Multiplicative.
Click the Preview icon to view the graph.
Instructions to obtain fitted values and residuals in Rguroo
- Use a dataset in your Rguroo account or recreate the example below by importing the USAccDeaths dataset from the Rguroo dataset repository called R Datasets into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Click on the
Analysis
dropdown menu and choose the Time Series function (see Figure 19.7) .Select your dataset from the Dataset dropdown menu. In this example, we select the USAccDeaths dataset.
From the Numerical Variables section, select and drag the variable USAccDeaths to the
Selected
column.(Optional) Under the Time Specification section, from the Type dropdown, select the time frequency of your data (yearly, quarterly, monthly, daily, hourly, by minute or seconds). The USAccDeaths data are monthly, so we select Month from the Type dropdown menu. Then set an appropriate start month and year for the data. The USAccDeaths data starts from January 1, 1973 so set
Year
to \(\tt{1973}\) andMonth
to \(\tt{1}\).Click on the button to open the modeling dialog.
In the Methods and Forecasting dialog under the Method section
- Check the modeling method(s) you would like to use (Exponential, Double Exponential, and/or Holt-Winters). Alpha, Beta, and Gamma parameters may be optionally specified in the text fields. For this example, we choose the (Exponential and Double Exponential methods with default values of Alpha and Beta.
- Select the Fitted Values Table checkbox.
- Click the Preview icon to view the graph.