# percentChange: Various Time Series Calculations In tfplot: Time Frame User Utilities

## Description

Calculate various conversions of time series.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ``` percentChange(obj, ...) ## Default S3 method: percentChange(obj, base=NULL, lag=1, cumulate=FALSE, e=FALSE, ...) ytoypc(obj, names = paste("y to y %ch", seriesNames(obj))) ## Default S3 method: ytoypc(obj, names = paste("y to y %ch", seriesNames(obj))) annualizedGrowth(obj, ...) ## Default S3 method: annualizedGrowth(obj, lag=1, freqLagRatio=frequency(obj)/lag, names=paste("Annual Growth of", seriesNames(obj)), ...) ```

## Arguments

 `obj` An object on which the calculation is to be done. The default method works for a time series vector or matrix (with columns corresponding to series, which are treated individually). `e` If e is TRUE the exponent of the series is used (after cumulating if cumulate is TRUE). e can be a logical vector with elements corresponding to columns of obj. `base` If base is provided it is treated as the first period value (that is, prior to differencing). It is prefixed to the m prior to cumulating. It should be a vector of length dim(m). (If e is TRUE then base should be log of the original data). `lag` integer indicating the number of periods relative to which the change should be calculated. `cumulate` logical indicating if the series should be cumulated before the percent change is calculated. `freqLagRatio` the ratio of `obj`'s frequency to the number of lags. `names` gives new names to be given to the calculated series. `...` arguments passed to other methods.

## Details

`percentChange` calculate the percent change relative to the data lag periods prior. If `cumulate` is TRUE then the data is cumulated first. `cumulate` can be a logical vector with elements corresponding to columns of obj.

The result is a time series of the year over year percent change. This uses percentChange with lag=frequency(obj).

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.

`annualizedGrowth` calculates the year to year percentage growth rate using `100*((obj/shift(obj, periods= -lag))^freqLagRatio - 1)`. The default gives the annualized one period growth. If `lag` is equal to the frequency of `obj` then the result is year-over-year growth.

## Value

A time series or time series matrix.

`diff`

## Examples

 ```1 2 3 4 5``` ```z <- ts(matrix(100 + rnorm(200),100,2), start=c(1990,1), frequency=12) z[z == 0] <- 1 # not to likely, but it can happen zyypc <- ytoypc(z) zpc <- percentChange(z) zag <- annualizedGrowth(z) ```

### Example output

```Loading required package: tframe
```

tfplot documentation built on May 2, 2019, 4:47 p.m.