ts_pcy and ts_diffy calculate the percentage change rate and the difference compared to the previous period, ts_pcy and ts_diffy calculate the percentage change rate compared to the same period of the previous year. ts_pca calculates annualized percentage change rates compared to the previous period.

ts_pc(x)

ts_diff(x)

ts_pca(x)

ts_pcy(x)

ts_diffy(x)

Arguments

x

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

Value

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

Examples

tail(ts_diff(ts_c(fdeaths, mdeaths)))
#> fdeaths mdeaths #> Jul 1979 -24 -19 #> Aug 1979 -26 -81 #> Sep 1979 14 -35 #> Oct 1979 18 141 #> Nov 1979 76 213 #> Dec 1979 87 47
tail(ts_pc(ts_c(fdeaths, mdeaths)))
#> fdeaths mdeaths #> Jul 1979 -5.594406 -1.767442 #> Aug 1979 -6.419753 -7.670455 #> Sep 1979 3.693931 -3.589744 #> Oct 1979 4.580153 15.000000 #> Nov 1979 18.491484 19.703978 #> Dec 1979 17.864476 3.632148
tail(ts_pca(ts_c(fdeaths, mdeaths)))
#> fdeaths mdeaths #> Jul 1979 -49.88442 -19.26433 #> Aug 1979 -54.89650 -61.62147 #> Sep 1979 54.53971 -35.51201 #> Oct 1979 71.15566 435.02501 #> Nov 1979 666.02981 765.57158 #> Dec 1979 618.77866 53.43838
tail(ts_pcy(ts_c(fdeaths, mdeaths)))
#> fdeaths mdeaths #> Jul 1979 -6.032483 -3.825137 #> Aug 1979 4.696133 -2.888446 #> Sep 1979 1.550388 -3.092784 #> Oct 1979 -4.418605 -5.175439 #> Nov 1979 14.588235 16.576577 #> Dec 1979 -15.463918 -25.993377
tail(ts_diffy(ts_c(fdeaths, mdeaths)))
#> fdeaths mdeaths #> Jul 1979 -26 -42 #> Aug 1979 17 -29 #> Sep 1979 6 -30 #> Oct 1979 -19 -59 #> Nov 1979 62 184 #> Dec 1979 -105 -471