Closed christophsax closed 5 years ago
As mentioned above, for conversion = "first"
, we get an unsmoothed result, contrary to what we get with conversion = "average"
:
library(tsbox)
library(tempdisagg)
data(swisspharma)
m.first <- td(sales.a ~ 1, to = "monthly", conversion = "first", method = "denton-cholette")
m.avg <- td(sales.a ~ 1, to = "monthly", conversion = "average", method = "denton-cholette")
ts_plot(first = predict(m.first), average = predict(m.avg))
But this is the correct result. It is the result of minimizing the sum of squared deviations between the differences of the resulting series and the indicator series. You can get a smoother series by minimizing the sum of squared deviations between the second differences (h = 2
).
m.first.h2 <- td(sales.a ~ 1, to = "monthly", conversion = "first", method = "denton-cholette", h = 2)
ts_plot(first_h2 = predict(m.first.h2), first = predict(m.first))
But note that this is not optimal with respect to the first differences (h = 1
):
sum(diff(predict(m.first))^2, na.rm = TRUE)
#> [1] 4742.853
sum(diff(predict(m.first.h2))^2, na.rm = TRUE)
#> [1] 5730.583
Smoothness can only be bought by increasing the square sum of the deviations of the first differences. If you want a smoother series, use h = 2
.
Created on 2019-08-19 by the reprex package (v0.3.0)
Got this from here, and was surprised that there is no smoothing if
conversion = "first"
.Is this a feature or a bug?