Description Usage Arguments Details See Also Examples

Lag, shift forward, or difference a tframe or tframed object.

1 2 3 4 5 6 7 8 9 10 |

`x` |
a tframed object. |

`lag` |
difference calculated relative to lag periods previous. |

`differences` |
order of differencing. |

`p` |
number of periods to shift or lag periods for differencing. |

`...` |
arguments to be passed to other methods. |

`tfL`

methods shift the time frame, or the time frame of the object, by
`p`

periods. (This might also be thought of as the exponent of the lag
operator.) Positive `p`

means shift the time frame forward and negative
`p`

means shift the time frame back. Shifting the time frame forward
means the data at a point in time is the data from the previous point in time
in the unshifted data, so the result corresponds to what is often called
the lagged data. The default `p`

(+1) means
the start and end for the results are one period later. When applied to a
data object, the default result is one lag of the data.
This convention is not the same as that used for `k`

in the
function `lag`

.

Note that the time frame of the data is shifted, but a vector or matrix
representation of the data is unchanged. This means that operations on the
data, such as `+, -, *, and /`

, need to be time aware as, for example,
operations on ts objects are. If the operations do not recognize the time
framed aspect of the objects, then the operation will be performed with
default methods that will probably have unintended results (see examples).

Differencing methods create a time frame or time framed object
by differencing the number
of times indicated by `differences`

at a lagged number of periods indicated
by `lag`

. (Positive values of `lag`

indicate number of periods back.)
The default is take the difference from data one period previous.
See `diff`

for more details, but note that the result when
applied to a time frame is a time frame, not a series.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
z <- ts(rnorm(100), start=c(1982,1), frequency=12)
tfstart(z)
Tobs(z)
z <- diff(z)
tfstart(z)
Tobs(z)
ts(1:5) - tfL(ts(1:5))
(1:5) - tfL(1:5) # (1:5) this is not a tframed object, so minus is the default
ts(1:5) - tfL(ts(1:5), p= 2)
z <- ts(1:10, start=c(1992,1), frequency=4)
z - tfL(z)
z <- ts(matrix(1:10,5,2), start=c(1992,1), frequency=4)
seriesNames(z) <- c("One", "Two")
z - tfL(z)
``` |

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.