knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

The first step of modelling infectious disease outbreaks is to fit out model to data. This vignette fits an exponential kernel with a constant exogenous term to some fake data.

# Loads the library
library(epihawkes)

# Sets the seed
set.seed(6)

# Initialise
parameters <- list(alpha = 0.98890929785557,
                   delta = 0.397745453286915,
                   A = 0.115697778761387,  
                   B = 0.0697486787103112,
                   delay = 12)
T_max <- 37
print_level <- 1

# Parameterise kernels
mu_term <- "linear"
mu_fn <- mu_linear

N_runs <- 1

events <- hawkes_simulation(events = c(0), kernel = ray_kernel, 
                            T_max = T_max,
                            parameters = parameters, mu_fn = mu_fn,
                            print_level = print_level)

print(sprintf("Number of events: %f", length(events)))

We can now plot our events count over time.

plot_events(events, T_max)

We can also plot the intensity of our kernel over time.

plot_intensity(events, T_max, kernel = ray_kernel,
               parameters = parameters, mu_fn = mu_fn)


mrc-ide/epihawkes documentation built on Feb. 13, 2021, 10:20 a.m.