This outline discusses the reasons that methods assuming continuous variables are unsuited for discrete data.
In assessing differences between March and April (H_0 = no difference, H_1 = difference) the task is to determine whether they merely due to random variation. In doing so, consideration must be given to seasonality and trend. The reprex below illustrates this with discretized monthly energy usage serving as a proxy for prescriptions.
suppressPackageStartupMessages({
library(fpp3)
})
series <- tsibble(
Month = rep(yearmonth("2018,1")) + 0:24,
Scripts = c(
7432, 6330, 7086, 6886, 7290, 6976,
7334, 6539, 5941, 7034, 6814, 5509, 6530, 5126, 5694, 5572, 6027,
5246, 5922, 5608, 6240, 7070, 6257, 6257, 6433
)
)
#> Using `Month` as index variable.
series
#> # A tsibble: 25 x 2 [1M]
#> Month Scripts
#> <mth> <dbl>
#> 1 2018 Jan 7432
#> 2 2018 Feb 6330
#> 3 2018 Mar 7086
#> 4 2018 Apr 6886
#> 5 2018 May 7290
#> 6 2018 Jun 6976
#> 7 2018 Jul 7334
#> 8 2018 Aug 6539
#> 9 2018 Sep 5941
#> 10 2018 Oct 7034
#> # … with 15 more rows
decomp <- stl(series, s.window = "periodic")
autoplot(decomp) + theme_minimal()
#> Error: Objects of type stl not supported by autoplot.
## NOTE: Error above is due to `reprex` environment; plot attached separately
Created on 2020-12-28 by the reprex package (v0.3.0.9001)