Skip to contents

Compute Moving Average of Time Series

Usage

ComputeMovingAverage(ma_window_length = 52)

Arguments

ma_window_length

length of moving average window, this will depend on the time scale in the data. Defaults to 52, so that weekly data is averaged over years.

Value

a function to remove to compute the moving average of a time series variable

## Returned Function

- Arguments * `data` data frame containing time series data * `series_variable` column name of series variable in `data`, default is "deaths" * `time_variable` column name of time variable in `data`, default is "period_end_date" - Return - all fields in `data` with the `series_variable` data replaced with the moving average.