4  Model Fitting

Model fitting requires an events object, created by make_events().

Fit models using fit_hawkesNet().

Example

First simulate some data (or use your own, and plug it into the make_events() function).

set.seed(1)

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

time <- 50

sim <- sim_hawkesNet(
  params = params_ba,
  T_end = time,
  mark_type = "ba"
)
[1] "Simulation took 1.06 seconds"
events <- sim$ev
class(events)
[1] "events" "list"  

And then fitting the model. Make sure you specify a mark_type. Can be one of: ba, cs, ba_bip, cs_bip.

params_init <- list(
  mu = 5,
  K = 0.3,
  beta = 1,
  beta_edges = 1
)

fit <- fit_hawkesNet(
    ev = sim$ev,
    params_init = params_init,
    mark_type = "ba"
)
[1] "Fitting took 4.02 seconds"

And we can see the fitted values:

unlist(fit$par)
        mu          K       beta beta_edges 
 2.1922311  0.4817160  0.7720289  0.5505869 

Not terrible!

Internally, the network is built incrementally event-by-event, for each iteration of the likelihood, rather than rebuilding the whole network up until that event, per-event.

Still need to add a proper summary() function, as well as return std. errs. This should be really quick to implement, I’m just lazy.

Also eventually this page (as well as Simulation) would contain all the argument information.