
Fit a Hawkes (self-exciting point process) model by maximum likelihood
Source:R/hawkes_fit.R
morie_hawkes_fit.RdFits a one-dimensional Hawkes process with a constant baseline to a
vector of event times. The conditional intensity is
$$lambda(t) = nu + eta * sum_{t_j < t} g(t - t_j),$$
where nu = exp(a0) is the baseline rate, eta the
branching ratio, and g the chosen triggering kernel.
Usage
morie_hawkes_fit(
times,
end_time = NULL,
kernel = c("exponential", "weibull", "lomax", "gamma")
)Value
An object of class morie_hawkes_fit: a list with the
parameter estimate, loglik, aic,
branching_ratio, baseline_rate, n_events,
converged and the backend used: from 50 events the fit is
rmoriebricklayer::core_hawkes_fit() (bounded, analytic gradient), which also
reports at_bound, the parameters on their bound, and a note when the
kernel shape is not identified (a Lomax at its exponential limit).
Details
The negative log-likelihood is evaluated by the shared morie C++ core (the same kernels the Python package uses); without a compiled core it falls back to a pure-R \(O(n^2)\) likelihood.
Examples
set.seed(1)
ev <- cumsum(rexp(200, rate = 2))
fit <- morie_hawkes_fit(ev, kernel = "exponential")
print(fit)
#> morie Hawkes fit -- exponential kernel, constant baseline
#> events: 200 horizon: 100 backend: rmoriebricklayer core
#> estimate:
#> a0 0.692284
#> eta 0.001
#> beta 0.1
#> baseline rate nu : 1.99828
#> branching ratio : 0.001
#> logLik: -61.3685 AIC: 128.737 converged: TRUE
#> vs Poisson: logLik -61.3674 (gain -0.00114)