logdiff: Take logarithm and then first differences of a time series.

View source: R/detrendfilters.R

logdiffR Documentation

Take logarithm and then first differences of a time series.

Description

logdiff logarithmizes and then takes first differences of a time series.

Usage

logdiff(y)

Arguments

y

univariate time series indexed as 1,..,T. Can be either a numeric vector or matrix, or a class ts object in which case the dates are correctly passed to the returned components.

Details

The first observation of the series are required as the initial value for the the first differences. The second observation will thereby be the first observation of the detrended series.

Value

Returns a class 'ts' object containing the log-differenced series. If the provided series y is of class ts, the dates of the detrended series will be set accordingly.

Examples

 data(INDPRO, package="tsfilters")
 IP_logdiff <- logdiff(INDPRO)
 start(INDPRO)
 start(IP_logdiff)
 plot(IP_logdiff)

saviviro/tsfilters documentation built on July 16, 2025, 6:16 p.m.