lag                  package:stats                  R Documentation

Lag a Time Series

Description:

     Compute a lagged version of a time series, shifting the time base
     back by a given number of observations.

Usage:

     lag(x, ...)

     ## Default S3 method:
     lag(x, k = 1, ...)

Arguments:

       x: A vector or matrix or univariate or multivariate time series

       k: The number of lags (in units of observations).

     ...: further arguments to be passed to or from methods.

Details:

     Vector or matrix arguments 'x' are coerced to time series.

     'lag' is a generic function; this page documents its default
     method.

Value:

     A time series object.

Note:

     Note the sign of 'k': a series lagged by a positive 'k' starts
     _earlier_.

References:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

See Also:

     'diff', 'deltat'

Examples:

     data(UKLungDeaths)
     lag(ldeaths, 12) # starts one year earlier

