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 object of the same class as x, i.e., an object of class ts, xts, zoo, data.frame, data.table, tbl, tbl_ts, tbl_time, tis, irts or timeSeries.

Examples

x <- ts_c(fdeaths, mdeaths) ts_diff(x)
#> fdeaths mdeaths #> Jan 1974 NA NA #> Feb 1974 -212 -271 #> Mar 1974 138 14 #> Apr 1974 -150 0 #> May 1974 -155 -385 #> Jun 1974 -116 -243 #> Jul 1974 35 31 #> Aug 1974 -48 -149 #> Sep 1974 -6 78 #> Oct 1974 195 283 #> Nov 1974 -4 129 #> Dec 1974 88 225 #> Jan 1975 164 257 #> Feb 1975 -78 34 #> Mar 1975 33 16 #> Apr 1975 -121 -320 #> May 1975 -197 -430 #> Jun 1975 -29 -115 #> Jul 1975 -17 -102 #> Aug 1975 -9 -53 #> Sep 1975 -69 -80 #> Oct 1975 97 294 #> Nov 1975 91 198 #> Dec 1975 240 521 #> Jan 1976 -4 -46 #> Feb 1976 374 730 #> Mar 1976 -245 -467 #> Apr 1976 -364 -804 #> May 1976 -85 -290 #> Jun 1976 -27 -29 #> Jul 1976 -44 -47 #> Aug 1976 -46 -143 #> Sep 1976 27 29 #> Oct 1976 88 209 #> Nov 1976 101 259 #> Dec 1976 218 592 #> Jan 1977 98 181 #> Feb 1977 -202 -606 #> Mar 1977 3 88 #> Apr 1977 -20 79 #> May 1977 -141 -555 #> Jun 1977 -110 -84 #> Jul 1977 19 -75 #> Aug 1977 -63 -74 #> Sep 1977 39 -54 #> Oct 1977 -2 220 #> Nov 1977 26 50 #> Dec 1977 227 426 #> Jan 1978 158 364 #> Feb 1978 57 265 #> Mar 1978 -116 -342 #> Apr 1978 -191 -519 #> May 1978 -16 -83 #> Jun 1978 -84 -153 #> Jul 1978 -15 -89 #> Aug 1978 -69 -94 #> Sep 1978 25 -34 #> Oct 1978 43 170 #> Nov 1978 -5 -30 #> Dec 1978 254 702 #> Jan 1979 142 451 #> Feb 1979 -36 -443 #> Mar 1979 -58 26 #> Apr 1979 -115 -315 #> May 1979 -134 -316 #> Jun 1979 -49 -140 #> Jul 1979 -24 -19 #> Aug 1979 -26 -81 #> Sep 1979 14 -35 #> Oct 1979 18 141 #> Nov 1979 76 213 #> Dec 1979 87 47
ts_pc(x)
#> fdeaths mdeaths #> Jan 1974 NA NA #> Feb 1974 -23.5294118 -12.6991565 #> Mar 1974 20.0290276 0.7514761 #> Apr 1974 -18.1378476 0.0000000 #> May 1974 -22.8951256 -20.5114544 #> Jun 1974 -22.2222222 -16.2868633 #> Jul 1974 8.6206897 2.4819856 #> Aug 1974 -10.8843537 -11.6406250 #> Sep 1974 -1.5267176 6.8965517 #> Oct 1974 50.3875969 23.4077750 #> Nov 1974 -0.6872852 8.6461126 #> Dec 1974 15.2249135 13.8803208 #> Jan 1975 24.6246246 13.9219935 #> Feb 1975 -9.3975904 1.6167380 #> Mar 1975 4.3882979 0.7487131 #> Apr 1975 -15.4140127 -14.8629819 #> May 1975 -29.6686747 -23.4588107 #> Jun 1975 -6.2098501 -8.1967213 #> Jul 1975 -3.8812785 -7.9192547 #> Aug 1975 -2.1377672 -4.4688027 #> Sep 1975 -16.7475728 -7.0609003 #> Oct 1975 28.2798834 27.9202279 #> Nov 1975 20.6818182 14.6993318 #> Dec 1975 45.1977401 33.7216828 #> Jan 1976 -0.5188067 -2.2265247 #> Feb 1976 48.7614081 36.1386139 #> Mar 1976 -21.4723926 -16.9818182 #> Apr 1976 -40.6250000 -35.2168200 #> May 1976 -15.9774436 -19.6078431 #> Jun 1976 -6.0402685 -2.4390244 #> Jul 1976 -10.4761905 -4.0517241 #> Aug 1976 -12.2340426 -12.8481581 #> Sep 1976 8.1818182 2.9896907 #> Oct 1976 24.6498599 20.9209209 #> Nov 1976 22.6966292 21.4403974 #> Dec 1976 39.9267399 40.3544649 #> Jan 1977 12.8272251 8.7906751 #> Feb 1977 -23.4338747 -27.0535714 #> Mar 1977 0.4545455 5.3855569 #> Apr 1977 -3.0165913 4.5876887 #> May 1977 -21.9284603 -30.8162132 #> Jun 1977 -21.9123506 -6.7415730 #> Jul 1977 4.8469388 -6.4543890 #> Aug 1977 -15.3284672 -6.8077277 #> Sep 1977 11.2068966 -5.3307009 #> Oct 1977 -0.5167959 22.9405631 #> Nov 1977 6.7532468 4.2408821 #> Dec 1977 55.2311436 34.6623271 #> Jan 1978 24.7648903 21.9939577 #> Feb 1978 7.1608040 13.1253096 #> Mar 1978 -13.5990621 -14.9737303 #> Apr 1978 -25.9158752 -26.7250257 #> May 1978 -2.9304029 -5.8327477 #> Jun 1978 -15.8490566 -11.4179104 #> Jul 1978 -3.3632287 -7.4978939 #> Aug 1978 -16.0092807 -8.5610200 #> Sep 1978 6.9060773 -3.3864542 #> Oct 1978 11.1111111 17.5257732 #> Nov 1978 -1.1627907 -2.6315789 #> Dec 1978 59.7647059 63.2432432 #> Jan 1979 20.9131075 24.8896247 #> Feb 1979 -4.3848965 -19.5757844 #> Mar 1979 -7.3885350 1.4285714 #> Apr 1979 -15.8184319 -17.0639220 #> May 1979 -21.8954248 -20.6401045 #> Jun 1979 -10.2510460 -11.5226337 #> Jul 1979 -5.5944056 -1.7674419 #> Aug 1979 -6.4197531 -7.6704545 #> Sep 1979 3.6939314 -3.5897436 #> Oct 1979 4.5801527 15.0000000 #> Nov 1979 18.4914842 19.7039778 #> Dec 1979 17.8644764 3.6321484
ts_pca(x)
#> fdeaths mdeaths #> Jan 1974 NA NA #> Feb 1974 -96.001168 -80.401570 #> Mar 1974 794.201619 9.399922 #> Apr 1974 -90.942718 0.000000 #> May 1974 -95.584478 -93.637107 #> Jun 1974 -95.099207 -88.155319 #> Jul 1974 169.743303 34.205519 #> Aug 1974 -74.913069 -77.351908 #> Sep 1974 -16.857903 122.620089 #> Oct 1974 13282.715194 1147.700265 #> Nov 1974 -7.942697 170.501888 #> Dec 1974 447.717591 375.755899 #> Jan 1975 1303.609692 377.849254 #> Feb 1975 -69.403132 21.222432 #> Mar 1975 67.425573 9.363926 #> Apr 1975 -86.585297 -85.498223 #> May 1975 -98.535175 -95.956639 #> Jun 1975 -53.667391 -64.165751 #> Jul 1975 -37.813542 -62.844260 #> Aug 1975 -22.841915 -42.224641 #> Sep 1975 -88.914307 -58.468125 #> Oct 1975 1885.649896 1819.865014 #> Nov 1975 854.337820 418.478386 #> Dec 1975 8680.480518 3169.053296 #> Jan 1976 -6.051072 -23.677493 #> Feb 1976 11645.820662 3952.993363 #> Mar 1976 -94.501194 -89.282867 #> Apr 1976 -99.808026 -99.453554 #> May 1976 -87.619143 -92.712742 #> Jun 1976 -52.652047 -25.644411 #> Jul 1976 -73.498976 -39.124001 #> Aug 1976 -79.111217 -80.799221 #> Sep 1976 156.951593 42.404937 #> Oct 1976 1307.024107 877.276268 #> Nov 1976 1064.103462 928.864434 #> Dec 1976 5533.892947 5744.061711 #> Jan 1977 325.565964 174.852734 #> Feb 1977 -95.940804 -97.729882 #> Mar 1977 5.592996 87.660617 #> Apr 1977 -30.758043 71.303718 #> May 1977 -94.872414 -98.797592 #> Jun 1977 -94.859703 -56.723012 #> Jul 1977 76.469257 -55.096417 #> Aug 1977 -86.421585 -57.089970 #> Sep 1977 257.750832 -48.178505 #> Oct 1977 -6.028280 1092.181491 #> Nov 1977 119.065057 64.610272 #> Dec 1977 19477.006370 3455.931470 #> Jan 1978 1322.684724 986.575354 #> Feb 1978 129.314523 339.255661 #> Mar 1978 -82.693012 -85.722982 #> Apr 1978 -97.266608 -97.604103 #> May 1978 -30.016006 -51.381811 #> Jun 1978 -87.390210 -76.657302 #> Jul 1978 -33.670162 -60.751826 #> Aug 1978 -87.675321 -65.835390 #> Sep 1978 122.858259 -33.861208 #> Oct 1978 254.070616 594.380322 #> Nov 1978 -13.094814 -27.386473 #> Dec 1978 27554.775088 35711.505146 #> Jan 1979 876.518767 1339.846939 #> Feb 1979 -41.612753 -92.677793 #> Mar 1979 -60.191387 18.556045 #> Apr 1979 -87.335031 -89.409367 #> May 1979 -94.846317 -93.759591 #> Jun 1979 -72.688048 -76.986311 #> Jul 1979 -49.884419 -19.264331 #> Aug 1979 -54.896500 -61.621467 #> Sep 1979 54.539707 -35.512008 #> Oct 1979 71.155657 435.025011 #> Nov 1979 666.029813 765.571580 #> Dec 1979 618.778659 53.438385
ts_pcy(x)
#> fdeaths mdeaths #> Jan 1974 NA NA #> Feb 1974 NA NA #> Mar 1974 NA NA #> Apr 1974 NA NA #> May 1974 NA NA #> Jun 1974 NA NA #> Jul 1974 NA NA #> Aug 1974 NA NA #> Sep 1974 NA NA #> Oct 1974 NA NA #> Nov 1974 NA NA #> Dec 1974 NA NA #> Jan 1975 -7.8801332 -1.4526710 #> Feb 1975 9.1436865 14.7074611 #> Mar 1975 -5.0785973 14.7043154 #> Apr 1975 -1.9202363 -2.3441662 #> May 1975 -10.5363985 -5.9651475 #> Jun 1975 7.8817734 3.1224980 #> Jul 1975 -4.5351474 -7.3437500 #> Aug 1975 4.8346056 0.1768347 #> Sep 1975 -11.3695090 -12.9032258 #> Oct 1975 -24.3986254 -9.7184987 #> Nov 1975 -8.1314879 -4.6884639 #> Dec 1975 15.7657658 11.9176598 #> Jan 1976 -7.5903614 -3.9467427 #> Feb 1976 51.7287234 28.6850725 #> Mar 1976 14.1401274 6.0380864 #> Apr 1976 -19.8795181 -19.3126023 #> May 1976 -4.2826552 -15.2530292 #> Jun 1976 -4.1095890 -9.9378882 #> Jul 1976 -10.6888361 -6.1551433 #> Aug 1976 -19.9029126 -14.3865843 #> Sep 1976 4.0816327 -5.1282051 #> Oct 1976 1.1363636 -10.3192279 #> Nov 1976 2.8248588 -5.0485437 #> Dec 1976 -0.9079118 -0.3388190 #> Jan 1977 12.3859192 10.8910891 #> Feb 1977 -42.1560035 -40.5818182 #> Mar 1977 -26.0044643 -24.5729304 #> Apr 1977 20.8646617 21.7714672 #> May 1977 12.3042506 4.7939445 #> Jun 1977 -6.6666667 0.1724138 #> Jul 1977 9.3085106 -2.3360288 #> Aug 1977 5.4545455 4.4329897 #> Sep 1977 8.4033613 -4.0040040 #> Oct 1977 -13.4831461 -2.4006623 #> Nov 1977 -24.7252747 -16.2235855 #> Dec 1977 -16.4921466 -19.6211753 #> Jan 1978 -7.6566125 -9.8660714 #> Feb 1978 29.2424242 39.7796818 #> Mar 1978 11.1613876 12.7758420 #> Apr 1978 -15.0855365 -20.9883398 #> May 1978 5.5776892 7.5441413 #> Jun 1978 13.7755102 2.1514630 #> Jul 1978 4.8661800 1.0119595 #> Aug 1978 4.0229885 -0.8884501 #> Sep 1978 0.0000000 1.1470282 #> Oct 1978 11.6883117 -3.3078880 #> Nov 1978 3.4063260 -9.6826688 #> Dec 1978 6.4263323 9.4864048 #> Jan 1979 3.1407035 12.0851907 #> Feb 1979 -7.9718640 -20.3152364 #> Mar 1979 -1.3568521 -4.9433574 #> Apr 1979 12.0879121 7.5895994 #> May 1979 -9.8113208 -9.3283582 #> Jun 1979 -3.8116592 -9.4355518 #> Jul 1979 -6.0324826 -3.8251366 #> Aug 1979 4.6961326 -2.8884462 #> Sep 1979 1.5503876 -3.0927835 #> Oct 1979 -4.4186047 -5.1754386 #> Nov 1979 14.5882353 16.5765766 #> Dec 1979 -15.4639175 -25.9933775
ts_diffy(x)
#> fdeaths mdeaths #> Jan 1974 NA NA #> Feb 1974 NA NA #> Mar 1974 NA NA #> Apr 1974 NA NA #> May 1974 NA NA #> Jun 1974 NA NA #> Jul 1974 NA NA #> Aug 1974 NA NA #> Sep 1974 NA NA #> Oct 1974 NA NA #> Nov 1974 NA NA #> Dec 1974 NA NA #> Jan 1975 -71 -31 #> Feb 1975 63 274 #> Mar 1975 -42 276 #> Apr 1975 -13 -44 #> May 1975 -55 -89 #> Jun 1975 32 39 #> Jul 1975 -20 -94 #> Aug 1975 19 2 #> Sep 1975 -44 -156 #> Oct 1975 -142 -145 #> Nov 1975 -47 -76 #> Dec 1975 105 220 #> Jan 1976 -63 -83 #> Feb 1976 389 613 #> Mar 1976 111 130 #> Apr 1976 -132 -354 #> May 1976 -20 -214 #> Jun 1976 -18 -128 #> Jul 1976 -45 -73 #> Aug 1976 -82 -163 #> Sep 1976 14 -54 #> Oct 1976 5 -139 #> Nov 1976 15 -78 #> Dec 1976 -7 -7 #> Jan 1977 95 220 #> Feb 1977 -481 -1116 #> Mar 1977 -233 -561 #> Apr 1977 111 322 #> May 1977 55 57 #> Jun 1977 -28 2 #> Jul 1977 35 -26 #> Aug 1977 18 43 #> Sep 1977 30 -40 #> Oct 1977 -60 -29 #> Nov 1977 -135 -238 #> Dec 1977 -126 -404 #> Jan 1978 -66 -221 #> Feb 1978 193 650 #> Mar 1978 74 220 #> Apr 1978 -97 -378 #> May 1978 28 94 #> Jun 1978 54 25 #> Jul 1978 20 11 #> Aug 1978 14 -9 #> Sep 1978 0 11 #> Oct 1978 45 -39 #> Nov 1978 14 -119 #> Dec 1978 41 157 #> Jan 1979 25 244 #> Feb 1979 -68 -464 #> Mar 1979 -10 -96 #> Apr 1979 66 108 #> May 1979 -52 -125 #> Jun 1979 -17 -112 #> Jul 1979 -26 -42 #> Aug 1979 17 -29 #> Sep 1979 6 -30 #> Oct 1979 -19 -59 #> Nov 1979 62 184 #> Dec 1979 -105 -471