Calculate coefficients for a moving difference
Value
A matrix with moving average coefficients
One row for each window and and one column for each year in the data.
The format of the row names is
difference_{window mid point start}_{window mid point end}_{window length}
.
difference_2001.5_2010.5_4
is the difference of the average for period for
the years 2009 to 2012 compared to the period from 2000 to 2003.
Examples
moving_difference(6, 2)
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> difference_1.5_5.5_2 -0.5 -0.5 0.0 0.0 0.5 0.5
#> difference_2.5_5.5_2 0.0 -0.5 -0.5 0.0 0.5 0.5
#> difference_3.5_5.5_2 0.0 0.0 -0.5 -0.5 0.5 0.5
#> difference_1.5_4.5_2 -0.5 -0.5 0.0 0.5 0.5 0.0
#> difference_2.5_4.5_2 0.0 -0.5 -0.5 0.5 0.5 0.0
#> difference_1.5_3.5_2 -0.5 -0.5 0.5 0.5 0.0 0.0
moving_difference(6, 2, 2000)
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> difference_2000.5_2004.5_2 -0.5 -0.5 0.0 0.0 0.5 0.5
#> difference_2001.5_2004.5_2 0.0 -0.5 -0.5 0.0 0.5 0.5
#> difference_2002.5_2004.5_2 0.0 0.0 -0.5 -0.5 0.5 0.5
#> difference_2000.5_2003.5_2 -0.5 -0.5 0.0 0.5 0.5 0.0
#> difference_2001.5_2003.5_2 0.0 -0.5 -0.5 0.5 0.5 0.0
#> difference_2000.5_2002.5_2 -0.5 -0.5 0.5 0.5 0.0 0.0