How to Compute a Moving Average
|Related Online Training modules|
|Time Series Plots|
|Generally it is best to access online training from within Q by selecting Help > Online Training|
A basic moving (rolling) average can be placed on a table using Modify Whole Table or Plot - Replace with Rolling Averages.
- Ensure that your date data is set up as a Date question (see Creating Date Variables).
- Ensure that your date question is in the appropriate unit (e.g., if you want to show a 5 month moving average, ensure that the date question shows months). See Setting Time Periods for Date Questions.
- Create a table with the Date question in the Brown Drop-down Menu.
- Right-click on the row labels that you wish to smooth (not on the date categories) and select Time Series Analysis, which opens the dialog box shown below.
- Set the Moving Average as Uniform (centered) (or Lagged).
- Set the Bandwidth to the number of months that you wish to combine (e.g., three) and press OK.
Note that if you wish to show both the moving average and the un-smoothed data together you can copy a row in a table by left-clicking on the blue row header, holding down the Ctrl button on your keyboard and moving the mouse until the word Copy appears in a small box and then releasing the mouse button.
For more detail on the options that are available, see Time Series Analysis.
You can create new variables for rolling time periods by right-clicking a Date question in the Variables and Questions tab, and selecting Insert Ready-Made Formulas > Date -> Moving Average. Detail about the options for this feature are described at Construct Moving Average.