diff --git a/R/FIN_plot.R b/R/FIN_plot.R index 508b8a6b4ab4a9223ec37ab8ee88b9626dfbd65a..6c46abf0678351988fe9158c85bee554ee482294 100644 --- a/R/FIN_plot.R +++ b/R/FIN_plot.R @@ -213,7 +213,7 @@ plot_sirplus <- function(x, comp_remove, theme_bw() + theme(axis.text.x = element_text(angle = 90)) if(length(unique(plot_df$experiment)) > 1){ - p <- p + facet_grid(reo_exp(experiment) ~ ., scale = 'free') + p <- p + facet_grid(reo_exp(experiment) ~ ., scales = 'free') } if(sep_compartments){ diff --git a/R/MOD_recovery.R b/R/MOD_recovery.R index dfce50a59d5c0d0e5b03a12b12ef1e6e2535763c..5d93feb119ad7b5f62909a98956d19f823167964 100644 --- a/R/MOD_recovery.R +++ b/R/MOD_recovery.R @@ -114,7 +114,7 @@ recovery.FUN <- function(dat, at, seed = NULL) { rand = dat$control$rec.rand, active, status = dat$attr$status, - label = c("i", "q", "h"), + label = c("i", "q"), state = recovState, at, expTime = dat$attr$expTime, diff --git a/R/original_plot_models.R b/R/original_plot_models.R index 049b888b35caf2a4d8afcf57af2d1d1d8335f5a0..016b614b573ea6cffa460a17adc8fa35ff177ba6 100644 --- a/R/original_plot_models.R +++ b/R/original_plot_models.R @@ -87,7 +87,7 @@ plot_models <- function(sims = baseline_sim, } else ( plot_df %>% ggplot(aes(x = Date, y = count, colour = compartment, linetype = sim)) + - facet_grid(reo_exp(experiment) ~ ., scale = 'free') + + facet_grid(reo_exp(experiment) ~ ., scales = 'free') + scale_x_date(date_breaks = "1 week", date_labels = "%m-%d") + geom_line(size = 1.5, alpha = 0.8) + scale_colour_manual(values = compcols, labels = complabels) + @@ -109,7 +109,7 @@ plot_models <- function(sims = baseline_sim, } else ( plot_df %>% ggplot(aes(x = Date, y = count+1, colour = compartment, linetype = sim)) + - facet_grid(reo_exp(experiment) ~ ., scale = 'free') + + facet_grid(reo_exp(experiment) ~ ., scales = 'free') + scale_y_continuous(trans = trans) + scale_x_date(date_breaks = "1 week", date_labels = "%m-%d") + geom_line(size = 1.5, alpha = 0.8) + diff --git a/tests/testthat/.DS_Store b/tests/testthat/.DS_Store index c75274b698af4eb48b88f2e123d3eb21760bb0ce..83ee8de8d1227601f3384dd2fcf93d92c9374316 100644 Binary files a/tests/testthat/.DS_Store and b/tests/testthat/.DS_Store differ diff --git a/tests/testthat/test-all-modules.R b/tests/testthat/test-all-modules.R deleted file mode 100644 index 1c7107f731df74b2b9c4593a756c18a50dd54f8c..0000000000000000000000000000000000000000 --- a/tests/testthat/test-all-modules.R +++ /dev/null @@ -1,28 +0,0 @@ -test_that("All modules(MOD) produce the same result as Churches' modules (.seiqhrf.icm)", { - - param <- param_seiqhrf(arec.rate = 0) - init <- init_seiqhrf(s.num = 1000) - - #### default functions: initialize.FUN, infection.FUN, recovery.FUN, departures.FUN, arrivals.FUN - control1 <- control_seiqhrf(nsteps = 10) - ### Churches' original function: - control2 <- control1 - control2$initialize.FUN <- "initialize.icm" - control2$infection.FUN <- "infection.seiqhrf.icm" - control2$recovery.FUN <- "progress.seiqhrf.icm" - control2$departures.FUN <- "departures.seiqhrf.icm" - control2$arrivals.FUN <- "arrivals.seiqhrf.icm" - - No_seeds <- 10 - seed_list <- sample(1:1000, No_seeds) - comp <- rep(NA, No_seeds) - i <- 1 - for(seed in seed_list){ - sim1 <- seiqhrf(param = param, init = init, control = control1, seed) - sim2 <- seiqhrf(param = param, init = init, control = control2, seed) - comp[i] <- identical(sim1, sim2) - i <- i + 1 - } - - expect_equal(sum(comp), No_seeds) -}) diff --git a/tests/testthat/test-recovery.R b/tests/testthat/test-recovery.R deleted file mode 100644 index 527a3e3df9563073e328b273e49394cd5775ad77..0000000000000000000000000000000000000000 --- a/tests/testthat/test-recovery.R +++ /dev/null @@ -1,23 +0,0 @@ -test_that("Identical output as Churches' original function: recovery.FUN", { - - control <- control_seiqhrf() - param <- param_seiqhrf(arec.rate = 0) - init <- init_seiqhrf() - - at <- 2 - dat <- do.call(initialize.FUN, list(param, init, control)) - dat <- do.call(infection.FUN, list(dat, at)) - - No_seeds <- 10 - seed_list <- sample(1:1000, No_seeds) - comp <- rep(NA, No_seeds) - i <- 1 - for(seed in seed_list){ - dat1 <- do.call(recovery.FUN, list(dat, at, seed)) - dat2 <- do.call(progress.seiqhrf.icm, list(dat, at, seed)) - comp[i] <- identical(dat1, dat2) - i <- i + 1 - } - - expect_equal(sum(comp), No_seeds) -}) \ No newline at end of file diff --git a/tests/testthat/test-seiqhrf-simulate.R b/tests/testthat/test-seiqhrf-simulate.R deleted file mode 100644 index 9581007b4751cb627f6b6a33994d5b1ba1404b87..0000000000000000000000000000000000000000 --- a/tests/testthat/test-seiqhrf-simulate.R +++ /dev/null @@ -1,32 +0,0 @@ -test_that("seiqhrf and simulate_seiqhrf produce identical output", { - - s.num = 1000 - q.num = 10 - nsteps = 10 - nsims = 3 - arec.rate = 0 ### has to be fixed 0 for comparison - - No_seeds <- 10 - seed_list <- sample(1:1000, No_seeds) - comp <- rep(NA, No_seeds) - i <- 1 - for(seed in seed_list){ - Churhes_res <- simulate_seiqhrf(nsteps = nsteps, nsims = nsims, - arec.rate = arec.rate, s.num = s.num, q.num = q.num, - infection.FUN = infection.seiqhrf.icm, - recovery.FUN = progress.seiqhrf.icm, - departures.FUN = departures.seiqhrf.icm, - arrivals.FUN = arrivals.seiqhrf.icm, seed = seed)$sim - class(Churhes_res) <- "seiqhrf" - - param <- param_seiqhrf(arec.rate = arec.rate) - init <- init_seiqhrf(s.num = s.num, q.num = q.num) - control <- control_seiqhrf(nsteps = nsteps, nsims = nsims) - sirplus_res <- seiqhrf(init, control, param, seed) - - comp[i] <- identical(Churhes_res[3:4], sirplus_res[3:4]) # Due to $usr.specified in control and param, can only compare "epi" and "times - i <- i + 1 - } - - expect_equal(sum(comp), No_seeds) -})