X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=pkg%2Ftests%2Ftestthat%2Ftest-Forecaster.R;fp=pkg%2Ftests%2Ftestthat%2Ftest.Forecaster.R;h=9b3eaa0e66c5f849cf8fa26815774d4b8cf51558;hp=a02e6e94b66e0e8bbca095383b95335284a9f7ef;hb=3ddf1c12af0c167fe7d3bb59e63258550270cfc5;hpb=102bcfda4afbb5cfee885cbee0f55545624168fd diff --git a/pkg/tests/testthat/test.Forecaster.R b/pkg/tests/testthat/test-Forecaster.R similarity index 93% rename from pkg/tests/testthat/test.Forecaster.R rename to pkg/tests/testthat/test-Forecaster.R index a02e6e9..9b3eaa0 100644 --- a/pkg/tests/testthat/test.Forecaster.R +++ b/pkg/tests/testthat/test-Forecaster.R @@ -43,16 +43,20 @@ test_that("Average method behave as expected", test_that("Persistence method behave as expected", { #Situation A: +Zero; (generally) correct if jump, wrong otherwise - pred00_sd = computeForecast(data00, indices, "Persistence", "Zero", Inf, 24, same_day=TRUE) - pred00_dd = computeForecast(data00, indices, "Persistence", "Zero", Inf, 24, same_day=FALSE) + pred00_sd = computeForecast(data00, indices, "Persistence", "Zero", Inf, 24, + same_day=TRUE) + pred00_dd = computeForecast(data00, indices, "Persistence", "Zero", Inf, 24, + same_day=FALSE) for (i in 1:7) { expect_equal(pred00_sd$getSerie(i), rep(pred_order[i],24)) expect_equal(pred00_dd$getSerie(i), rep(pred_order[i],24)) } - pred13_sd = computeForecast(data13, indices, "Persistence", "Zero", Inf, 24, same_day=TRUE) - pred13_dd = computeForecast(data13, indices, "Persistence", "Zero", Inf, 24, same_day=FALSE) + pred13_sd = computeForecast(data13, indices, "Persistence", "Zero", Inf, 24, + same_day=TRUE) + pred13_dd = computeForecast(data13, indices, "Persistence", "Zero", Inf, 24, + same_day=FALSE) for (i in 2:6) { expect_equal(pred13_sd$getSerie(i), c( rep(i,11), rep(i%%7+1,13) ) ) @@ -105,18 +109,21 @@ test_that("Persistence method behave as expected", 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") + 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") + 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 + 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 @@ -128,8 +135,10 @@ test_that("Neighbors method behave as expected", 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") + #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) ) )