---
title: "Sensitivity Analysis (Flies)"
author: "Melanie Cousins"
date: '2018-02-26'
output: html_document
---

Model
```{r}
require(deSolve)

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}
```
Starting Conditions
```{r}
xstart <- c(Sh=8e+06, Eh= 0, Ih= 9, Rh=4.57e+06, B=2.5e-02, Sf=4.91e+03, If= 0)    

mu_bh <-0.000027
mu_dh <-0.000020
mu_i <- 0.000009

Sh_min <- 1e6 
Sh_max <- 1e7

B_min <- 1e-2
B_max <- 4e-2

Sf_min <- 100
Sf_max <- 10000

w_min <- 100
w_max <- 10000

gamma <- 0.65
gamma_min <- 0.333
gamma_max <- 1

lambda <- 0.0467
lambda_min <- 0.027
lambda_max <- 0.14

beta_i <- 1e-13 #1e-13
beta_i_min <-0
beta_i_max <-1e-11

beta_f <- 1e-11 #2.071838e-11 #2e-11
beta_f_min <- 0
beta_f_max <-1e-9

beta_e <- 5e-11 #5e-11
beta_e_min <- 0
beta_e_max <- 5e-9

beta_b <- 3.2e-07 #1e-7
beta_b_min <- 0
beta_b_max <- 1e-5

zeta <- 2.2e-02 #2.2e-02
zeta_min <- 0
zeta_max <- 1e-1

mu_b <- 2.15e-3 #1.873401e-03 #1.9e-03
mu_b_min <-1e-4 
mu_b_max <-2.5e-3

mu_d <- 1.65e-03 #1.048914e-03 #1.05e-03
mu_d_min <-1e-4
mu_d_max <-2.5e-3

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i, gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
```
Wintering of FLies:
```{r}
w <- 4.91e+03

baseline <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

baseline$incidence <- (baseline$Ih/(baseline$Sh+baseline$Eh+baseline$Ih+baseline$Rh))*100000
baseline_incidence <- sum(baseline$incidence[1:365])
baseline_incidence
```
GAMMA:
(0.33, 0.65, 1)
```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma_min, lambda=lambda, zeta=zeta, beta=beta, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_gammamin  <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma_max, lambda=lambda,zeta=zeta, beta=beta, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)

w <- 4.91e+03

df_gammamax<- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_gammamin$incidence <- (df_gammamin$Ih/(df_gammamin$Sh+df_gammamin$Eh+df_gammamin$Ih+df_gammamin$Rh))*100000
df_gammamin_incidence <- sum(df_gammamin$incidence[1:365])
df_gammamin_incidence

df_gammamax$incidence <- (df_gammamax$Ih/(df_gammamax$Sh+df_gammamax$Eh+df_gammamax$Ih+df_gammamax$Rh))*100000
df_gammamax_incidence <- sum(df_gammamax$incidence[1:365])
df_gammamax_incidence
```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_gammamin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_gammamax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  theme_bw()
```

LAMBDA:
(0.027, 0.0467, 0.14)

```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, gamma=gamma, lambda=lambda_min, beta=beta, zeta=zeta, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_lambdamin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, gamma=gamma, lambda=lambda_max, zeta=zeta, beta=beta, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_lambdamax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))


df_lambdamin$incidence <- (df_lambdamin$Ih/(df_lambdamin$Sh+df_lambdamin$Eh+df_lambdamin$Ih+df_lambdamin$Rh))*100000
df_lambdamin_incidence <- sum(df_lambdamin$incidence[1:365])
df_lambdamin_incidence

df_lambdamax$incidence <- (df_lambdamax$Ih/(df_lambdamax$Sh+df_lambdamax$Eh+df_lambdamax$Ih+df_lambdamax$Rh))*100000
df_lambdamax_incidence <- sum(df_lambdamax$incidence[1:365])
df_lambdamax_incidence


```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_lambdamin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_lambdamax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
BETA I:
(0, 1e-13, 1e-10)
```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda,zeta=zeta, beta_i=beta_i_min, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)

w <- 4.91e+03

df_betaimin<- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda,zeta=zeta, beta_i=beta_i_max, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_betaimax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_betaimin$incidence <- (df_betaimin$Ih/(df_betaimin$Sh+df_betaimin$Eh+df_betaimin$Ih+df_betaimin$Rh))*100000
df_betaimin_incidence <- sum(df_betaimin$incidence[1:365])
df_betaimin_incidence

df_betaimax$incidence <- (df_betaimax$Ih/(df_betaimax$Sh+df_betaimax$Eh+df_betaimax$Ih+df_betaimax$Rh))*100000
df_betaimax_incidence <- sum(df_betaimax$incidence[1:365])
df_betaimax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_betaimin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_betaimax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
BETA F:
(0, 1e-11, 1e-10)
```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda,zeta=zeta, beta_i=beta_i, beta_f=beta_f_min, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_betafmin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda,zeta=zeta, beta_i=beta_i, beta_f=beta_f_max, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_betafmax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_betafmin$incidence <- (df_betafmin$Ih/(df_betafmin$Sh+df_betafmin$Eh+df_betafmin$Ih+df_betafmin$Rh))*100000
df_betafmin_incidence <- sum(df_betafmin$incidence[1:365])
df_betafmin_incidence

df_betafmax$incidence <- (df_betafmax$Ih/(df_betafmax$Sh+df_betafmax$Eh+df_betafmax$Ih+df_betafmax$Rh))*100000
df_betafmax_incidence <- sum(df_betafmax$incidence[1:365])
df_betafmax_incidence


```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_betafmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_betafmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
BETA B:
(0, 3.2e-7, 1e-6
```{r}

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}
params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda,zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b_min, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_betabmin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh,  mu_i=mu_i, gamma=gamma, lambda=lambda, zeta=zeta,beta_i=beta_i, beta_f=beta_f, beta_b=beta_b_max, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_betabmax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_betabmin$incidence <- (df_betabmin$Ih/(df_betabmin$Sh+df_betabmin$Eh+df_betabmin$Ih+df_betabmin$Rh))*100000
df_betabmin_incidence <- sum(df_betabmin$incidence[1:365])
df_betabmin_incidence

df_betabmax$incidence <- (df_betabmax$Ih/(df_betabmax$Sh+df_betabmax$Eh+df_betabmax$Ih+df_betabmax$Rh))*100000
df_betabmax_incidence <- sum(df_betabmax$incidence[1:365])
df_betabmax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_betabmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_betabmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
BETA E:
(0, 5e-11 1e-10)
```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh,  mu_i=mu_i, gamma=gamma, lambda=lambda, zeta=zeta,beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e_min, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_betaemin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda_max,zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e_max, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_betaemax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_betaemin$incidence <- (df_betaemin$Ih/(df_betaemin$Sh+df_betaemin$Eh+df_betaemin$Ih+df_betaemin$Rh))*100000
df_betaemin_incidence <- sum(df_betaemin$incidence[1:365])
df_betaemin_incidence

df_betaemax$incidence <- (df_betaemax$Ih/(df_betaemax$Sh+df_betaemax$Eh+df_betaemax$Ih+df_betaemax$Rh))*100000
df_betaemax_incidence <- sum(df_betaemax$incidence[1:365])
df_betaemax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_betaemin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_betaemax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
ZETA:
(0, 2.2e-2, 1e-1)
```{r}

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta_min, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)
w <- 4.91e+03

df_zetamin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}


params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta_max, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)

w <- 4.91e+03

df_zetamax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_zetamin$incidence <- (df_zetamin$Ih/(df_zetamin$Sh+df_zetamin$Eh+df_zetamin$Ih+df_zetamin$Rh))*100000
df_zetamin_incidence <- sum(df_zetamin$incidence[1:365])
df_zetamin_incidence

df_zetamax$incidence <- (df_zetamax$Ih/(df_zetamax$Sh+df_zetamax$Eh+df_zetamax$Ih+df_zetamax$Rh))*100000
df_zetamax_incidence <- sum(df_zetamax$incidence[1:365])
df_zetamax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_betafmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_betafmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
MU B:
(1e-4, 2.15e-3, 3e-3)
```{r}

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}


params <- c(mu_bh=mu_bh, mu_dh=mu_dh,  mu_i=mu_i, gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b_min, mu_d=mu_d)

w <- 4.91e+03

df_mubmin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))


open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=4e-3, mu_d=mu_d)

w <- 4.91e+03

df_mubmax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_mubmin$incidence <- (df_mubmin$Ih/(df_mubmin$Sh+df_mubmin$Eh+df_mubmin$Ih+df_mubmin$Rh))*100000
df_mubmin_incidence <- sum(df_mubmin$incidence[1:365])
df_mubmin_incidence

df_mubmax$incidence <- (df_mubmax$Ih/(df_mubmax$Sh+df_mubmax$Eh+df_mubmax$Ih+df_mubmax$Rh))*100000
df_mubmax_incidence <- sum(df_mubmax$incidence[1:365])
df_mubmax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_mubmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_mubmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
MU D:
(1e-4, 1.65e-3, 2e-3
```{r}

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d_min)
w <- 4.91e+03

df_mudmin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}


params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=2.5e-3)

w <- 4.91e+03

df_mudmax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_mudmin$incidence <- (df_mudmin$Ih/(df_mudmin$Sh+df_mudmin$Eh+df_mudmin$Ih+df_mudmin$Rh))*100000
df_mudmin_incidence <- sum(df_mudmin$incidence[1:365])
df_mudmin_incidence

df_mudmax$incidence <- (df_mudmax$Ih/(df_mudmax$Sh+df_mudmax$Eh+df_mudmax$Ih+df_mudmax$Rh))*100000
df_mudmax_incidence <- sum(df_mudmax$incidence[1:365])
df_mudmax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_betafmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_betafmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
Sh:
(1e6, 8e6, 1e7) 
```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

xstart <- c(Sh=Sh_min, Eh= 0, Ih= 9, Rh=4.57e+06, B=2.5e-02, Sf=4.91e+03, If= 0)    

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)


df_Shmin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

xstart <- c(Sh=Sh_max, Eh= 0, Ih= 9, Rh=4.57e+06, B=2.5e-02, Sf=4.91e+03, If= 0)    

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)


df_Shmax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_Shmin$incidence <- (df_Shmin$Ih/(df_Shmin$Sh+df_Shmin$Eh+df_Shmin$Ih+df_Shmin$Rh))*100000
df_Shmin_incidence <- sum(df_Shmin$incidence[1:365])
df_Shmin_incidence

df_Shmax$incidence <- (df_Shmax$Ih/(df_Shmax$Sh+df_Shmax$Eh+df_Shmax$Ih+df_Shmax$Rh))*100000
df_Shmax_incidence <- sum(df_Shmax$incidence[1:365])
df_Shmax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_Shmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_Shmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
B:
(0,3.4e-7,1e-6)
```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}


xstart <- c(Sh=8e6, Eh= 0, Ih= 9, Rh=4.57e+06, B=B_min, Sf=4.91e+03, If= 0)    

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, mu_i=mu_i,  gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)


df_Bmin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}


xstart <- c(Sh=8e6, Eh= 0, Ih= 9, Rh=4.57e+06, B=B_max, Sf=4.91e+03, If= 0)    

params <- c(mu_bh=mu_bh, mu_dh=mu_dh, gamma=gamma, mu_i=mu_i,  lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)


df_Bmax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_Bmin$incidence <- (df_Bmin$Ih/(df_Bmin$Sh+df_Bmin$Eh+df_Bmin$Ih+df_Bmin$Rh))*100000
df_Bmin_incidence <- sum(df_Bmin$incidence[1:365])
df_Bmin_incidence

df_Bmax$incidence <- (df_Bmax$Ih/(df_Bmax$Sh+df_Bmax$Eh+df_Bmax$Ih+df_Bmax$Rh))*100000
df_Bmax_incidence <- sum(df_Bmax$incidence[1:365])
df_Bmax_incidence
```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_Bmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_Bmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```
Sf:
(100,5000,10000)
```{r}
open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

xstart <- c(Sh=8e6, Eh= 0, Ih= 9, Rh=4.57e+06, B=2.5e-02, Sf=Sf_min, If= 0)    

params <- c(mu_bh=mu_bh, mu_dh=mu_dh,  mu_i=mu_i, gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)

w <-w_min

df_Sfmin <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

open.sbeir.model <- function (t, x, params) {  #SIR model equations
  Sh <- x[1]
  Eh <- x[2]
  Ih <- x[3]
  Rh <- x[4]
  B <-  x[5]
  Sf <- x[6]
  If <- x[7]
  with( #we can simplify code using "with"
    as.list(params), #this argument to "with" lets us use the variable names
   
     { #human population
      dSh <- mu_bh*(Sh+Eh+Ih+Rh) + mu_i*(Sh+Eh+Ih+Rh) - beta_f*Sh*If - beta_i*Sh*Ih - beta_b*Sh*B - mu_dh*Sh
      dEh <- beta_f*Sh*If + beta_i*Sh*Ih + beta_b*Sh*B - gamma*Eh - mu_dh*Eh
      dIh <- gamma*Eh - lambda*Ih - mu_dh*Ih
      dRh <- lambda*Ih - mu_dh*Rh
      dB <-  zeta*sin(2*pi*t/365)*B
      
      #fly population
      dSf <- mu_b*(-100*sin(2*pi*t/365)) - beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*Sf
      dIf <- beta_e*Sf*B - mu_d*(-100*sin(2*pi*t/365))*If  
      dx <- (c(dSh,dEh,dIh,dRh,dB,dSf,dIf))
      list(dx) #return result as a list
    }
  )
}

xstart <- c(Sh=8e6, Eh= 0, Ih= 9, Rh=4.57e+06, B=2.5e-02, Sf=Sf_max, If= 0)    

params <- c(mu_bh=mu_bh, mu_dh=mu_dh,  mu_i=mu_i, gamma=gamma, lambda=lambda, zeta=zeta, beta_i=beta_i, beta_f=beta_f, beta_b=beta_b, beta_e=beta_e, mu_b=mu_b, mu_d=mu_d)

w <- w_max

df_Sfmax <- as.data.frame(ode(xstart, # start at initial condition
            seq(0,365,1), # solve from 0 to T
            open.sbeir.model,
            params,
            method='ode45',
            rtol=1e-7))

df_Sfmin$incidence <- (df_Sfmin$Ih/(df_Sfmin$Sh+df_Sfmin$Eh+df_Sfmin$Ih+df_Sfmin$Rh))*100000
df_Sfmin_incidence <- sum(df_Sfmin$incidence[1:365])
df_Sfmin_incidence

df_Sfmax$incidence <- (df_Sfmax$Ih/(df_Sfmax$Sh+df_Sfmax$Eh+df_Sfmax$Ih+df_Sfmax$Rh))*100000
df_Sfmax_incidence <- sum(df_Sfmax$incidence[1:365])
df_Sfmax_incidence

```
```{r}
ggplot(baseline, aes(x=time,y=Ih)) +
  geom_line(colour="black", size=0.3) +
  geom_line(data=df_Sfmin, aes(x=time, y=Ih), color="red", alpha=0.4) +
  geom_line(data=df_Sfmax, aes(x=time, y=Ih), color="blue", alpha=0.4) +
  xlab("Time") + ylab("Number of Cases") +
  scale_x_continuous(breaks = breaks, labels = xlabels) +
  theme_bw()
```