getMA: Compute a simple moving average for a given time series

Description Usage Arguments Details Value

View source: R/getMA.r

Description

Compute a moving average using prior or later elements

Usage

1
tsData.ma <- getMA(tsData,N)

Arguments

tsData

A time series object.

N

An integer indicating how many prior or later elements to include.

direction

A string indicating which elements to use to compute the moving average relative to each point. Valid values are "prior" and "later".

Details

If N is null and direction is "prior", then the current point and all prior points are used in the compuation. If N is null and direction is "later", then the current point and all later points are used in the computation. If N is not null, then an N point moving average is computed in the direction specified (default is "prior"). In any case, a one-sided (non-centered) moving average is computed. If direction is "prior", then the current point and the prior N-1 points are included in the computation. If direction is "later", then the current point and the later N-1 points are included in the computation. If there are not enough points to compute an N-point MA, then the original values are retained.

Value

A time series of moving averages


OHDSI/Castor documentation built on March 20, 2021, 6:09 p.m.