Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stats-lag

Lag a Time Series


Description

Compute a lagged version of a 'timeSeries' object.

Usage

## S4 method for signature 'timeSeries'
lag(x, k = 1, trim = FALSE, units = NULL, ...)

Arguments

k

[lagSeries] -
an integer value. The number of lags (in units of observations). By default 1.

trim

a logical value. By default TRUE, the first missing observation in the return series will be removed.

units

an optional character string, which allows to overwrite the current column names of a timeSeries object. By default NULL which means that the column names are selected automatically.

x

an object of class timeSeries.

...

arguments passed to other methods.

Value

returns a lagged S4 object of class 'timeSeries'.

Examples

## Load Micsrosoft Data Set -
   x = MSFT[1:20, "Open"]
   
## Lag the timeSeries Object:
   lag(x, k = -1:1)

timeSeries

Financial Time Series Objects (Rmetrics)

v3062.100
GPL (>= 2)
Authors
Diethelm Wuertz [aut] (original code), Tobias Setz [cre], Yohan Chalabi [ctb], Martin Maechler [ctb] (<https://orcid.org/0000-0002-8685-9910>)
Initial release
2020-01-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.