Skip to contents

Companion to the Markovian exponential / constant fit in morie_tps_hawkes_temporal_fit. Supports the four kernels (exponential, gamma, Weibull, Lomax) and two baselines (constant, sinusoidal) of Kwan-Chen-Dunsmuir (2024).

Usage

morie_tps_hawkes_advanced_fit(
  df,
  kernel = "gamma",
  baseline = "sinusoidal",
  ds_name = "?",
  max_n = 5000L
)

Arguments

df

A data frame with an OCC_DATE or REPORT_DATE column.

kernel

Excitation kernel: one of "exponential", "gamma", "weibull", "lomax".

baseline

Baseline kind: "constant" or "sinusoidal".

ds_name

Dataset name used in titles and warnings.

max_n

Maximum number of events to retain (for tractable O(n^2) MLE on the non-Markovian path).

Value

A morie_rich_result with branching ratio, stationarity verdict, kernel and baseline parameters, negative log-likelihood, AIC, BIC, and time-rescaling KS statistic.

Details

If the optional packages hawkes or emhawkes are available the (exponential, constant) special case can delegate to their compiled likelihood routines; the non-Markovian kernels always use the base-R O(n^2) negative log-likelihood with L-BFGS-B optimisation under explicit box constraints.

Goodness-of-fit is reported via time-rescaling residuals (Brown et al. 2002) and a Kolmogorov-Smirnov test against Uniform(0, 1).

References

Kwan TKJ, Chen F, Dunsmuir WTM (2024). Likelihood inference for non-stationary Hawkes processes. arXiv:2408.09710v1.

Examples

# \donttest{
  df <- morie_tps_load_tps_dataset("Assault", nrows = 4000)
#> morie_tps: no local TPS cache for 'Assault'; using the bundled sample from rmoriedata. Fetch the full export with morie_tps_fetch_category().
  rr <- morie_tps_hawkes_advanced_fit(df, kernel = "gamma",
                                        baseline = "sinusoidal",
                                        ds_name = "Assault")
  print(rr$summary_lines)
#> $events_fitted
#> [1] 999
#> 
#> $time_window_days
#> [1] 13633.4
#> 
#> $kernel
#> [1] "gamma"
#> 
#> $baseline
#> [1] "sinusoidal"
#> 
#> $branching_ratio
#> [1] 0.9708
#> 
#> $stationary
#> [1] "Yes (eta<1)"
#> 
#> $kernel_params
#> [1] 2.782 0.050
#> 
#> $baseline_params
#> [1] -9.6658  4.8434  1.3219  0.9820
#> 
#> $neg_log_likelihood
#> [1] 2572.9
#> 
#> $aic
#> [1] 5159.7
#> 
#> $bic
#> [1] 5194.1
#> 
#> $ks_stat
#> [1] 0.0248
#> 
#> $ks_pvalue
#> [1] 0.5725
#> 
# }