Skip to contents

Differencing of a series

Usage

differences(data, lags = 1, mean = TRUE)

Arguments

data

The series to be differenced.

lags

Lags of the differencing.

mean

Mean correction.

Value

The differenced series.

Examples

differences(retail$BookStores, c(1,1,12), FALSE)
#>       Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
#> 1993            219  -45    8  -31   15   90 -123   28   49   29
#> 1994 -111   65  -47   29   50   -8  -72  136 -153   -1   69   41
#> 1995   63 -289  147   41    5  -43   42  -34    0  -54  131  -86
#> 1996   29  -36   37    6   -8  -45   11  136 -283  387 -308  170
#> 1997  -23 -169  120  -18   -2   16    7 -109  280 -267  151   22
#> 1998 -346  453 -218    6    1   57  -47   43  -28  -64   27  116
#> 1999 -114   51    6  -39  -10   59   13 -188  131   79  -38   17
#> 2000 -207  266 -155   32  101 -124  -29  248 -224 -128  185 -128
#> 2001  296 -284  154 -125   78  -17   13  267 -495  227   -3   66
#> 2002  260 -780  471   72  -73  -93  143 -118  160 -208   81   51
#> 2003   62 -184   18  165 -108  162 -189  295 -511  226  -38  211
#> 2004 -163   48    7 -131   56   65   -3  -83   74   27   -7   54
#> 2005 -290  258   -1 -104   88  -94  154  -36 -165  109   65  -72
#> 2006   98 -228  111   23   67  -38 -191  165   77  -90   13 -117
#> 2007  234 -177   56    9    8  -50  197  -60 -266  214  -40  -49
#> 2008   73    4 -158  197 -127  -59   97  214 -405  204  -87  119
#> 2009   30 -148  192 -118   -1   81 -118   19  195 -289  116  -18
#> 2010   81  -42   11  -83   78    2  -34 -110  177   20    3  -84