ts_index returns an index series, with value of 1 at base date. ts_compound builds an index from percentage change rates, starting with 1 and compounding the rates.

ts_compound(x, denominator = 100)

ts_index(x, base = NULL)

Arguments

x

ts-boxable time series, an object of class ts, xts, zoo, data.frame, data.table, tbl, tbl_ts, tbl_time, or timeSeries.

denominator

numeric, set equal to one if percentage change rate is given a decimal fraction

base

base date, character string, Date or POSIXct, at which the

Value

a ts-boxable time series, with the same class as the input.

Examples

head(ts_compound(ts_pc(ts_c(fdeaths, mdeaths))))
#> fdeaths mdeaths #> Jan 1974 1.0000000 1.0000000 #> Feb 1974 0.7647059 0.8730084 #> Mar 1974 0.9178690 0.8795689 #> Apr 1974 0.7513873 0.8795689 #> May 1974 0.5793563 0.6991565 #> Jun 1974 0.4506104 0.5852858
head(ts_index(ts_df(ts_c(fdeaths, mdeaths)), "1974-02-01"))
#> id time value #> 1 fdeaths 1974-01-01 1.3076923 #> 2 fdeaths 1974-02-01 1.0000000 #> 3 fdeaths 1974-03-01 1.2002903 #> 4 fdeaths 1974-04-01 0.9825835 #> 5 fdeaths 1974-05-01 0.7576197 #> 6 fdeaths 1974-06-01 0.5892598
ts_plot( `My Expert Knowledge` = ts_chain( mdeaths, ts_compound(ts_bind(ts_pc(mdeaths), 15, 23, 33))), `So Far` = mdeaths, title = "A Very Manual Forecast" )