MA Function (CREATE command)

MA produces new series based on the centered moving averages of existing series.

  • The specification on MA is the name or names of the existing series and the span to be used in averaging, in parentheses.
  • A span must be specified; there is no default.
  • If the specified span is odd, the MA is naturally associated with the middle term. If the specified span is even, the MA is centered by averaging each pair of uncentered means 1.
  • After the initial span, a second span can be specified to indicate the minimum number of values to use in averaging when the number specified for the initial span is unavailable. This makes it possible to produce nonmissing values at or near the ends of the new series.
  • The second span must be greater than or equal to 1 and less than or equal to the first span.
  • The second span should be even (or 1) if the first span is even; it should be odd if the first span is odd. Otherwise, the next higher span value will be used.
  • If no second span is specified, the minimum span is simply the value of the first span.
  • If the number of values specified for the span or the minimum span is not available, the case in the new series is set to system-missing. Thus, unless a minimum span of 1 is specified, the endpoints of the new series will contain system-missing values.
  • When MA encounters an embedded missing value in the existing series, it creates two subsets, one containing cases before the missing value and one containing cases after the missing value. Each subset is treated as a separate series for computational purposes.
  • The endpoints of these subset series will have missing values according to the rules described above for the endpoints of the entire series. Thus, if the minimum span is 1, the endpoints of the subsets will be nonmissing; the only cases that will be missing in the new series are cases that were missing in the original series.

Example

CREATE TICKMA = MA(TICKETS,4,2).
  • This example creates the series TICKMA based on centered moving average values of the series TICKETS.
  • A span of 4 is used for computing averages. At the endpoints, where four values are not available, the average is based on the specified minimum of two values.
1 Velleman, P. F., and D. C. Hoaglin. 1981. Applications, basics, and computing of exploratory data analysis. Boston, Mass.: Duxbury Press.