Skip to contents

A Hawkes process with an exponential kernel, time in years: the rate baseline + sum(alpha * exp(-beta * (t - t_i))) over past events t_i. Each event has on average alpha / beta direct offspring (the branching ratio, below 1), so events cluster in time, as windstorm series and aftershocks do, and the stationary rate is baseline / (1 - alpha / beta). alpha = 0 is the Poisson process.

Usage

hawkes(baseline, alpha, beta)

hawkes_simulate(process, horizon, seed, stream = 0)

hawkes_counts(process, n_years, burn_in = 0, seed = 0)

hawkes_event_set(process, severity, n_years, burn_in = 0, seed = 0)

hawkes_moments(process, horizon = 1)

hawkes_log_likelihood(process, periods, horizon = 1)

Arguments

baseline

Rate of the background events, a year; positive.

alpha

The rise in the rate at each event; at least 0 and below beta.

beta

The excitation's decay rate, a year; positive.

process

A hawkes process.

horizon

Length of a path or period, in years.

seed

Seed, a whole number.

stream

Stream of the seed.

n_years

Number of independent years.

burn_in

Years simulated before each year and dropped.

severity

A severity, as for simulate_events().

periods

A list of sorted numeric vectors of event times.

Value

hawkes() an S7 hawkes object with properties baseline, alpha, beta, branching_ratio and stationary_rate; hawkes_simulate() a vector of times, hawkes_counts() a vector of counts, hawkes_event_set() an event_set, hawkes_moments() c(mean, variance) and hawkes_log_likelihood() a number.

Details

  • hawkes_simulate(): one path's event times on [0, horizon) from an empty history, drawn exactly by the branching construction from stream stream of seed.

  • hawkes_counts(): the number of events in each of n_years independent years, year i from stream i - 1 of seed, after burn_in years whose events excite the year and are dropped.

  • hawkes_event_set(): those years as an event_set with times in [0, 1) and a loss from severity each, for apply_tower() and hours_clause().

  • hawkes_moments(): the mean count over horizon years from an empty history and the stationary variance of the count over such a window (Hawkes and Oakes' formula).

  • hawkes_log_likelihood(): the log-likelihood of event times, each period a sorted vector on [0, horizon) from an empty history.

See also

hawkes_fit() to fit one to event times.

Examples

h <- hawkes(2, 12, 24)
h@branching_ratio
#> [1] 0.5
h@stationary_rate
#> [1] 4
mean(hawkes_counts(h, 2000, seed = 1))
#> [1] 3.695
hawkes_moments(h)
#>      mean  variance 
#>  3.833334 15.000006 
ev <- hawkes_event_set(h, lognormal_from_mean_cv(10, 1), 100, seed = 7)
ev@has_times
#> [1] TRUE