+ #boundaries are special cases: OK if same day, quite wrong otherwise
+ expect_equal(pred13_sd$getSerie(1), c( rep(1,11), rep(2,13) ) )
+ expect_equal(pred13_dd$getSerie(1), c( rep(1,11), rep(-5,13) ) )
+ expect_equal(pred13_sd$getSerie(7), c( rep(7,11), rep(1,13) ) )
+ expect_equal(pred13_dd$getSerie(7), c( rep(7,11), rep(8,13) ) )
+
+ #A few extra checks
+ expect_equal( pred00_sd$getIndexInData(3), dateIndexToInteger("2007-04-03",data00) )
+ expect_equal( pred00_dd$getIndexInData(6), dateIndexToInteger("2007-04-06",data00) )
+ expect_equal( pred13_sd$getIndexInData(3), dateIndexToInteger("2007-04-03",data13) )
+ expect_equal( pred13_dd$getIndexInData(6), dateIndexToInteger("2007-04-06",data13) )
+})
+
+test_that("Neighbors method behave as expected",
+{
+ #Situation A: +Zero; correct if jump, wrong otherwise
+ pred00 = computeForecast(data00, indices, "Neighbors", "Zero", Inf, 24, simtype="mix")
+ for (i in 1:7)
+ expect_equal(pred00$getSerie(i), rep(pred_order[i],24))
+
+ pred13 = computeForecast(data13, indices, "Persistence", "Zero", Inf, 24, simtype="mix")
+ for (i in 1:7)
+ expect_equal(pred13$getSerie(i), c( rep(i,11), rep(i%%7+1,13) ) )
+
+ #Situation B: +Neighbors, always predict bad (small, averaged) jump
+ pred00 = computeForecast(data00, indices, "Neighbors", "Neighbors", Inf, 24, simtype="endo")
+ #Concerning weights, there are 12+(1 if i>=2) gaps at -6 and 90-12+(i-2 if i>=3) gaps at 1
+ #Thus, predicted jump is respectively
+ # (12*-6+78)/90 = 0.06666667
+ # (13*-6+78)/91 = 0
+ # (13*-6+79)/92 = 0.01086957
+ # (13*-6+80)/93 = 0.02150538
+ # (13*-6+81)/94 = 0.03191489
+ # (13*-6+82)/95 = 0.04210526
+ # (13*-6+83)/96 = 0.05208333
+ jumps = c(0.06666667, 0, 0.01086957, 0.02150538, 0.03191489, 0.04210526, 0.05208333)
+ for (i in 1:7)
+ expect_equal(pred00$getSerie(i), rep(pred_order[i]+jumps[i],24))
+
+ #Next lines commented out because too unpredictable results (tendency to flatten everything...)
+# pred13 = computeForecast(data13, indices, "Neighbors", "Neighbors", Inf, 24, simtype="endo")
+# for (i in 1:7)
+# expect_equal(pred13$getSerie(i), c( rep(i,11), rep(i%%7+1,13) ) )