File tree Expand file tree Collapse file tree 1 file changed +5
-21
lines changed
Expand file tree Collapse file tree 1 file changed +5
-21
lines changed Original file line number Diff line number Diff line change @@ -44,26 +44,10 @@ sim_multiple_chains <- epichains::simulate_chains(
4444 generation_time = function (x ) generate(x = ebola_serialinter , times = x )
4545)
4646
47- # visualize ----------------------------------------
47+ # summarise ----------------------------------------
48+
49+ summary(sim_multiple_chains )
4850
49- sim_chains_aggregate <-
50- sim_multiple_chains %> %
51- # use data.frame output from <epichains> object
52- as_tibble() %> %
53- # Count the daily number of cases in each chain
54- mutate(day = ceiling(time )) %> %
55- count(chain , day , name = " cases" ) %> %
56- # Calculate the cumulative number of cases for each chain
57- group_by(chain ) %> %
58- mutate(cumulative_cases = cumsum(cases )) %> %
59- ungroup()
51+ # visualize ----------------------------------------
6052
61- sim_chains_aggregate %> %
62- # Create grouped chain trajectories
63- ggplot(aes(x = day , y = cumulative_cases , group = chain )) +
64- geom_line() +
65- # Define a 100-case threshold
66- geom_hline(aes(yintercept = 100 ), lty = 2 ) +
67- ylim(0 ,100 ) +
68- xlim(0 ,100 ) +
69- labs(x = " Day" , y = " Cumulative cases" )
53+ # optional - not to assess
You can’t perform that action at this time.
0 commit comments