show_hawkes: Plot Hawkes intensity

View source: R/plots.r

show_hawkesR Documentation

Plot Hawkes intensity

Description

Plots a Hawkes intensity function, options to extend to non-homogeneous background intensity.

Plots a number of goodness-of-fit plots for a fitted Hawkes process. Includes 1) a comparison of the compensator and observed events, 2) a histogram of transformed interarrival times, 3) a Q-Q plot of transformed interarrival times, and 4) the CDF of consecutive interarrival times, In addition, results of a Kolmogorov-Smirnov and Ljung-Box hypothesis test for the interarrival times are printed.

Usage

show_hawkes(obj)

show_hawkes_GOF(
  obj,
  background_integral = NULL,
  plot = TRUE,
  return_values = FALSE
)

Arguments

obj

Either object returned by fit_hawkes/fit_hawkes_cbf or a named list with elements times and params. If the latter, then times should be a numeric vector of observed time points, and params must contain, alpha (intensity jump after an event occurrence) and beta (exponential intensity decay). In addition, should contain either mu (base rate of the Hawkes process) or background_parameters (parameter(s) for the assumed non-homogeneous background function; could be a list of multiple values). May also contain marks (a vector of numerical marks).

background_integral

Function, as defined in fit_hawkes_cbf.

plot

Logical, whether to plot goodness-of-fit plots. Default TRUE.

return_values

Logical, whether to return GOF values. Default FALSE.

Value

show_hawkes returns a gtable object with geom_line and geom_histogram values.

show_hawkes_GOF returns no value unless return_values = TRUE, in this case a list of interarrival times is returned.

Examples

data(retweets_niwa, package = "stelfi")
times <- unique(sort(as.numeric(difftime(retweets_niwa, min(retweets_niwa),units = "mins"))))
params <- c(mu = 9, alpha = 3, beta = 10)
show_hawkes(list(times = times, params = params))
fit <- fit_hawkes(times = times, parameters = params)
show_hawkes(fit)
data(retweets_niwa, package = "stelfi")
times <- unique(sort(as.numeric(difftime(retweets_niwa, min(retweets_niwa),units = "mins"))))
params <- c(mu = 9, alpha = 3, beta = 10)
show_hawkes_GOF(list(times = times, params = params))
fit <- fit_hawkes(times = times, parameters = params)
show_hawkes_GOF(fit)

cmjt/stelfi documentation built on Oct. 25, 2023, 2:53 p.m.