Epidemic Duration

Summarize the epidemic duration of simulated outbreaks

Detection Summary

summarize_detections() returns a summary of detection events by iteration.

Code
detect_summary <- summarize_detections(detection)

View a subset of detect_summary

Code
## Filter data to scenario
detect_summary_select <- detect_summary %>%
  filter(region == "central") %>%
  filter(scenario_type == "suboptimal") %>%
  filter(preclinical == 2)

## Select and order columns to display
detect_summary_select <- detect_summary_select[c("iteration", "farms_detected", "first_detect", "last_detect", "duration")]

## Check data
head(detect_summary_select)
iteration farms_detected first_detect last_detect duration
1 82 18 68 50
2 13 18 36 18
3 179 18 90 72
4 10 18 44 26
5 20 18 49 31
6 115 18 118 100

Summary Statistics

generate_detect_statistics() returns summary statistics for each modeling scenario. Results are grouped by region, scenario_type, and preclinical.

Code
detect_config_summary <- generate_detect_statistics(detect_summary)

Epidemic Duration

The number of days between the first detection and last detection in a single outbreak

Code
duration_summary <- detect_config_summary %>%         
  filter(summary == "duration")
Code
## Filter to central region
duration_central_summary <- duration_summary %>%
  filter(region == "central")

## Select and order columns
duration_central_summary <- duration_central_summary[c("scenario_type", "preclinical", "mean", "q05", "q25", "q50", "q75", "q95")]

duration_central_summary
scenario_type preclinical mean q05 q25 q50 q75 q95
optimal 0 15.8400 2.00 2.00 13.0 22.00 45.00
optimal 1 21.9520 2.00 8.00 17.0 28.00 61.00
optimal 2 28.7140 2.00 12.00 23.0 37.00 75.00
optimal 3 44.3140 6.00 15.00 28.0 59.00 135.00
suboptimal 0 48.5040 10.00 24.00 38.0 65.25 124.05
suboptimal 1 67.6460 14.00 28.00 53.0 93.25 181.00
suboptimal 2 90.3340 15.90 34.50 71.5 141.00 213.05
suboptimal 3 119.5380 17.95 48.00 108.0 189.00 243.00
low-virulence 6 308.7667 212.45 291.25 340.0 341.00 341.00
Code
## Filter to eastern region
duration_eastern_summary <- duration_summary %>%
  filter(region == "eastern")

## Select and order columns
duration_eastern_summary <- duration_eastern_summary[c("scenario_type", "preclinical", "mean", "q05", "q25", "q50", "q75", "q95")]

duration_eastern_summary
scenario_type preclinical mean q05 q25 q50 q75 q95
optimal 0 17.258 2.00 2.00 15.0 25.00 50.00
optimal 1 23.564 2.00 9.75 19.0 31.00 68.10
optimal 2 32.520 2.00 14.00 24.0 41.00 94.05
optimal 3 39.916 2.00 16.00 29.5 56.25 104.10
suboptimal 0 47.752 9.00 23.00 38.0 63.25 118.05
suboptimal 1 62.646 11.95 28.00 53.0 80.00 157.10
suboptimal 2 81.336 13.95 35.00 64.0 110.25 205.25
suboptimal 3 107.550 17.95 47.00 95.0 152.25 250.00
low-virulence 6 284.674 76.95 259.75 318.5 341.00 341.00

Significance Test

Perform significance testing on optimal and suboptimal detection scenarios

Code
## Filter out low virulence scenarios
no_LV_detect <- detection %>%
  filter(scenario_type != "low-virulence")

no_LV_detect_summary <- summarize_detections(no_LV_detect)

Linear Model

Code
## Filter to central region
no_LV_detect_central_summary <- no_LV_detect_summary %>%
  filter(region == "central")

model_central_duration <- lm(duration ~ preclinical * scenario_type, 
                       data = no_LV_detect_central_summary)

summary(model_central_duration)

Call:
lm(formula = duration ~ preclinical * scenario_type, data = no_LV_detect_central_summary)

Residuals:
    Min      1Q  Median      3Q     Max 
-117.54  -24.66   -7.84   15.38  227.46 

Coefficients:
                             Estimate Std. Error t value Pr(>|t|)    
(Intercept)                    32.172      1.479  21.749  < 2e-16 ***
preclinical1                   12.627      2.092   6.036 1.72e-09 ***
preclinical2                   27.352      2.092  13.075  < 2e-16 ***
preclinical3                   49.754      2.092  23.784  < 2e-16 ***
scenario_type.L                23.097      2.092  11.041  < 2e-16 ***
preclinical1:scenario_type.L    9.214      2.958   3.114  0.00186 ** 
preclinical2:scenario_type.L   20.475      2.958   6.921 5.21e-12 ***
preclinical3:scenario_type.L   30.094      2.958  10.172  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 46.78 on 3992 degrees of freedom
Multiple R-squared:  0.3411,    Adjusted R-squared:   0.34 
F-statistic: 295.3 on 7 and 3992 DF,  p-value: < 2.2e-16
Code
## Filter to eastern region
no_LV_detect_eastern_summary <- no_LV_detect_summary %>%
  filter(region == "eastern")

model_eastern_duration <- lm(duration ~ preclinical * scenario_type, 
                       data = no_LV_detect_eastern_summary)

summary(model_eastern_duration)

Call:
lm(formula = duration ~ preclinical * scenario_type, data = no_LV_detect_eastern_summary)

Residuals:
     Min       1Q   Median       3Q      Max 
-105.550  -22.672   -7.752   14.447  256.664 

Coefficients:
                             Estimate Std. Error t value Pr(>|t|)    
(Intercept)                    32.505      1.366  23.791  < 2e-16 ***
preclinical1                   10.600      1.932   5.486 4.37e-08 ***
preclinical2                   24.423      1.932  12.640  < 2e-16 ***
preclinical3                   41.228      1.932  21.338  < 2e-16 ***
scenario_type.L                21.563      1.932  11.160  < 2e-16 ***
preclinical1:scenario_type.L    6.073      2.733   2.222   0.0263 *  
preclinical2:scenario_type.L   12.956      2.733   4.741 2.20e-06 ***
preclinical3:scenario_type.L   26.262      2.733   9.611  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 43.2 on 3992 degrees of freedom
Multiple R-squared:  0.3075,    Adjusted R-squared:  0.3063 
F-statistic: 253.2 on 7 and 3992 DF,  p-value: < 2.2e-16

ANOVA

Code
anova(model_central_duration)
Df Sum Sq Mean Sq F value Pr(>F)
preclinical 3 1370030.7 456676.909 208.70868 0
scenario_type 1 2894493.8 2894493.800 1322.83017 0
preclinical:scenario_type 3 258144.5 86048.159 39.32539 0
Residuals 3992 8734922.7 2188.107 NA NA
Code
anova(model_eastern_duration)
Df Sum Sq Mean Sq F value Pr(>F)
preclinical 3 955037.2 318345.721 170.54314 0
scenario_type 1 2162854.5 2162854.542 1158.67744 0
preclinical:scenario_type 3 190807.1 63602.367 34.07285 0
Residuals 3992 7451698.8 1866.658 NA NA

Plot Duration

plot_epidemic_duration() returns a plot with median epidemic duration (days) on the x-axis and the duration of incubation phase transmission on the y-axis.

Code
central_duration_plot <- plot_epidemic_duration(duration_central_summary, "central")

central_duration_plot

Code
eastern_duration_plot <- plot_epidemic_duration(duration_eastern_summary, "eastern")

eastern_duration_plot