Description Usage Arguments Details Value

`lag`

creates a lagged version of a time series, shifting the time base
forward by a given number of observations. `Lag`

does exactly the
opposite, shifting the time base backwards by the given number of
observations. `lag`

and `Lag`

create a single lagged
series, while `lags`

and `Lags`

can create a multivariate
series with several lags at once.

1 2 3 4 5 6 |

`x` |
A vector or matrix or univariate or multivariate time series
(including |

`k` |
The number of lags. For |

`...` |
further arguments to be passed to or from methods |

`lags` |
vector of lag numbers. For code |

`name` |
string or a character vector of names to be used in constructing column names for the returned series |

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

For `lags`

, column names are constructed as follows: If
`name`

is supplied and has as many elements as `x`

has
columns, those names are used as the base column names. Otherwise the
column names of `x`

comprise the base column names, or if those
don't exist, the first `ncols(x)`

letters of the alphabet are
used as base names. Each column of the returned series has a name
consisting of the basename plus a suffix indicating the lag number for
that column.

Both functions return a time series (`ts`

or `tis`

) object.
If the `lags`

argument to the `lags`

function argument has
more than one element, the returned object will have a column for each
lag, with `NA`

's filling in where appropriate.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.