3  Simulation

Simulation is relatively straightforward for the core kernels (BA, BA_BIP, CS, BIP_CS).

Uses the usual hawkes Ogata thinning algorithm.

Example

Simulate data using the sim_hawkesNet() function. See ?hawkesNet::sim_hawkesNet for more information.

set.seed(1)

params_ba <- list(
  mu = 5,
  K = 0.5,
  beta = 0.8,
  beta_edges = 0.5
)

time <- 10

sim <- sim_hawkesNet(
  params = params_ba,
  T_end = time,
  return_ev = TRUE,
  debug = FALSE,
  mark_type = "ba"
)
[1] "Simulation took 0.33 seconds"

Return value

Simulation object contains events, accept_probs, net and ev.

events

Contains the times and number of total events simulated:

str(sim$events)
List of 2
 $ n: int 110
 $ t: num [1:110] 0.151 0.178 0.254 0.534 0.784 ...

accept_probs

Contains the acceptance probabilities from the thinning for each event:

str(sim$accept_probs)
 num [1:112] 1 0.998 0.99 0.955 0.987 ...

net

The final network created from the events:

plot(sim$net)

Notice that the time attributes are preserved in the network object:

sim$net
 Network attributes:
  vertices = 110 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 121 
    missing edges= 0 
    non-missing edges= 121 

 Vertex attribute names: 
    time vertex.names 

 Edge attribute names: 
    time 
Tip

All the vertex attributes are preserved. Additionally, edge attributes are supported, so if custom kernels are written which utilize these later i.e. weighted edges, toggle-able edges etc., the current framework does not eed to change.

ev

The events object which can be plugged directly into fit_hawkesNet().

str(sim$ev)
List of 3
 $ times:'data.frame':  110 obs. of  2 variables:
  ..$ event_id: int [1:110] 1 2 3 4 5 6 7 8 9 10 ...
  ..$ t       : num [1:110] 0.151 0.178 0.254 0.534 0.784 ...
 $ nodes:'data.frame':  110 obs. of  2 variables:
  ..$ event_id: int [1:110] 1 2 3 4 5 6 7 8 9 10 ...
  ..$ id      : chr [1:110] "1" "2" "3" "4" ...
 $ edges:'data.frame':  121 obs. of  3 variables:
  ..$ event_id: int [1:121] 2 3 3 5 6 7 7 8 9 9 ...
  ..$ i       : chr [1:121] "1" "1" "2" "2" ...
  ..$ j       : chr [1:121] "2" "3" "3" "5" ...
 - attr(*, "class")= chr [1:2] "events" "list"