library(otsad)
#> Warning: package 'otsad' was built under R version 3.5.3
# when data has non-zero variance, it's OK
vec <- rep(1:5, times = 5)
res <- CpSdEwma(data = vec, n.train = 5, threshold = 0.01, l = 3)
nrow(res) == length(vec)
#> [1] TRUE
# when data has zero variance, CpSdEwma() output has more rows than input
vec <- rep(0, 25)
res <- CpSdEwma(data = vec, n.train = 5, threshold = 0.01, l = 3)
nrow(res) == length(vec)
#> [1] FALSE
# adding just one different value to make data non-zero variance works
vec <- c(0.1, rep(0, 25))
res <- CpSdEwma(data = vec, n.train = 5, threshold = 0.01, l = 3)
nrow(res) == length(vec)
#> [1] TRUE
Issue: when data has zero variance,
CpSdEwma()
output has more rows than inputSuggestion:
length(input)
since it doesn't really matter when there's zero varianceCreated on 2019-06-20 by the reprex package (v0.2.1)