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

diffLog

Calculate the difference of log data


Description

Calculate the difference from lag periods prior for log of data.

Usage

diffLog(obj, lag=1, base = exp(1),
         names=paste("diff of log of ", seriesNames(obj)))
    ## Default S3 method:
diffLog(obj, lag=1, base = exp(1),
         names=paste("diff of log of ", seriesNames(obj)))

Arguments

obj

A time series object.

lag

The difference is calculated relative to lag periods prior.

base

Base to use when calculating logrithms.

names

names for the new series (but is details).

Details

The result is a time series of the difference relative to lag periods prior for the log of the data. lag data points are lost from the beginning of the series. Negative values will result in NAs.

The names are not applied to the new series if the global option ModSeriesNames is FALSE. This can be set with options(ModSeriesNames=FALSE). This provides a convenient mechanism to prevent changing series labels on plot axis, when the title may indicate that data is in year-to-year percent change so the axis label does not need this.

Value

A time series vector or matrix.

Examples

z <- matrix(100 + rnorm(200),100,2)
z[z <= 0] <- 1 # not to likely, but it can happen
z <- diffLog(z)

tfplot

Time Frame User Utilities

v2015.12-1
GPL-2
Authors
Paul Gilbert <pgilbert.ttv9z@ncf.ca>
Initial release

We don't support your browser anymore

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