Type: | Package |
Title: | Missing Data for Marked Hawkes Process |
Version: | 0.2.2 |
Date: | 2025-03-04 |
Description: | Estimation of model parameters for marked Hawkes process. Accounts for missing data in the estimation of the parameters. Technical details found in (Tucker et al., 2019 <doi:10.1016/j.spasta.2018.12.004>). |
Imports: | interp, extraDistr, Rcpp |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
SystemRequirements: | GNU GSL |
NeedsCompilation: | yes |
URL: | https://github.com/sandialabs/stpphawkes |
BugReports: | https://github.com/sandialabs/stpphawkes/issues |
LinkingTo: | Rcpp, RcppArmadillo, RcppProgress, RcppGSL |
RoxygenNote: | 7.3.2 |
Packaged: | 2025-03-10 21:45:47 UTC; jdtuck |
Author: | J. Derek Tucker [aut, cre], Lyndsay Shand [aut], Stephen Rowe [aut], John Lewis [aut] |
Maintainer: | J. Derek Tucker <jdtuck@sandia.gov> |
Repository: | CRAN |
Date/Publication: | 2025-03-10 22:10:02 UTC |
Marked Hawkes Process with Missing Data
Description
A library for estimation of spatio-temporal Hawkes process parameters with missing data support
Author(s)
Maintainer: J. Derek Tucker jdtuck@sandia.gov
Authors:
Lyndsay Shand lshand@sandia.gov
Stephen Rowe srowe@sandia.gov
John Lewis jrlewi@sandia.gov
References
J. D. Tucker, L. Shand, and J. R. Lewis, “Handling Missing Data in Self-Exciting Point Process Models,” Spatial Statistics, vol. 29. pp. 160-176, 2019.
See Also
Useful links:
Report bugs at https://github.com/sandialabs/stpphawkes/issues
Calculate area of polynomial
Description
Calculate area of polynomial
Usage
areapl(poly)
Arguments
poly |
- matrix describing polynomial |
Value
W - area of polynomial
Simulate a homogenous space-time Poisson process
Description
This function simulates a homogenous space-time Poisson process on W
, defined by polygon
Usage
homog.STPP(
mu,
poly,
t.region,
xfrac = 0.1,
yfrac = 0.1,
remove = FALSE,
checkpoly = TRUE,
showplot = FALSE
)
Arguments
mu |
- background parameter |
poly |
- matrix defining polygon ( |
t.region |
- vector of two elements describing time span |
xfrac |
- x fractional increase of polygon to handle boundary effects (default = .1) |
yfrac |
- y fractional increase (default = .1) |
remove |
- remove points outside polygon (default = FALSE) |
checkpoly |
- check if polygon is proper (default = TRUE) |
showplot |
- plot points (default = FALSE) |
Value
A DataFrame containing x
,y
,t
Examples
out = homog.STPP(0.5,matrix(c(0,0,1,1,0,1,1,0),ncol=2),c(0,10))
Calculate intensity function for temporal Hawkes
Description
Calculate intensity function for temporal Hawkes
Usage
intensity_temporal(mu, alpha, beta, times, evalpt)
Arguments
mu |
- background parameter |
alpha |
- alpha parameter |
beta |
- beta parameter |
times |
- history of previous times |
evalpt |
- point to evaluate |
Value
lambda - intensity at evalpt
Bayesian Estimation of Spatio-Temporal Hawkes Model Parameters
Description
This function computes the posterior of a spatio-temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
Usage
mcmc_stpp(
data,
poly,
t_max = max(data$t),
t_mis = NULL,
param_init = NULL,
mcmc_param = NULL,
branching = TRUE,
print = TRUE,
sp_clip = TRUE
)
Arguments
data |
- A DataFrame containing |
poly |
- matrix defining polygon ( |
t_max |
- maximum time value (default = max(times)) |
t_mis |
- vector of two elements describing missing time range (default = 'NULL') |
param_init |
- list of parameters of initial guess (default = 'NULL', will start with MLE) |
mcmc_param |
- list of mcmc parameters |
branching |
- using branching structure in estimation (default = 'TRUE') |
print |
- print progress (default = 'TRUE') |
sp_clip |
- when simulating missing data spatial points, clip spatial region back to observed region (default = 'TRUE') |
Details
The default is to estimate the branching structure.
The model will also account to missing data if t_mis
is provided.
Value
A List containing the mcmc samples (samps), branching structure ('y', if 'TRUE'), and missing data ('zsamps' if 't_mis' is not 'NULL') If 't_mis' is not 'NULL' the mcmc samples will contain 'n_missing', the number of missing points estimated
Bayesian Estimation of Spatio-Temporal Hawkes Model Parameters with non uniform spatial locations
Description
This function computes the posterior of a spatio-temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
Usage
mcmc_stpp_nonunif(
data,
poly,
t_max = max(data$t),
t_mis = NULL,
param_init = NULL,
mcmc_param = NULL,
branching = TRUE,
print = TRUE,
sp_clip = TRUE
)
Arguments
data |
- A DataFrame containing |
poly |
- matrix defining polygon ( |
t_max |
- maximum time value (default = max(times)) |
t_mis |
- vector of two elements describing missing time range (default = 'NULL') |
param_init |
- list of parameters of initial guess (default = 'NULL', will start with MLE) |
mcmc_param |
- list of mcmc parameters |
branching |
- using branching structure in estimation (default = 'TRUE') |
print |
- print progress (default = 'TRUE') |
sp_clip |
- when simulating missing data spatial points, clip spatial region back to observed region (default = 'TRUE') |
Details
The default is to estimate the branching structure.
The model will also account to missing data if t_mis
is provided.
Value
A List containing the mcmc samples (samps), branching structure ('y', if 'TRUE'), and missing data ('zsamps' if 't_mis' is not 'NULL') If 't_mis' is not 'NULL' the mcmc samples will contain 'n_missing', the number of missing points estimated
Bayesian Estimation of Temporal Hawkes Model Parameters
Description
This function computes the posterior of the parameters of a temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
Usage
mcmc_temporal(
times,
t_max = max(times),
t_mis = NULL,
param_init = NULL,
mcmc_param = NULL,
branching = TRUE,
print = TRUE
)
Arguments
times |
- vector of arrival times |
t_max |
- maximum time value (default = max(times)) |
t_mis |
- |
param_init |
- list of parameters of initial guess (default = 'NULL', will start with MLE) |
mcmc_param |
- list of mcmc parameters |
branching |
- using branching structure in estimation (default = 'TRUE') |
print |
- print progress (default = 'TRUE') |
Details
The default is to estimate the branching structure which is much more computationally efficient. The model will also account to missing data if t_mis
is provided.
Branching models specify gamma priors for mu, alpha and beta parameters.
Value
A List containing the mcmc samples (samps), branching structure ('y', if 'TRUE'), and missing data ('zsamps' if 't_mis' is not 'NULL') If 't_mis' is not 'NULL' the mcmc samples will contain 'n_missing', the number of missing points estimated
Examples
times = simulate_temporal(.5,.1,.5,c(0,10),numeric())
out = mcmc_temporal(times)
Bayesian Estimation of Temporal Hawkes Model Parameters with Categorical Marks
Description
This function computes the posterior of the parameters of a temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
Usage
mcmc_temporal_catmark(
times,
marks,
t_max = max(times),
t_mis = NULL,
param_init = NULL,
mcmc_param = NULL,
branching = TRUE,
print = TRUE
)
Arguments
times |
- vector of arrival times |
marks |
- vector of marks |
t_max |
- maximum time value (default = max(times)) |
t_mis |
- |
param_init |
- list of parameters of initial guess (default = 'NULL, will start with MLE) |
mcmc_param |
- list of mcmc parameters |
branching |
- using branching structure in estimation (default = 'TRUE') |
print |
- print progress (default = 'TRUE') |
Details
The default is to estimate the branching structure which is much more computationally efficient. The model will also account to missing data if t_mis
is provided.
Value
A List containing the mcmc samples (samps), branching structure ('y', if 'TRUE'), and missing data ('zsamps' if 't_mis' is not 'NULL') If 't_mis' is not 'NULL' the mcmc samples will contain 'n_missing', the number of missing points estimated
Bayesian Estimation of Temporal Hawkes Model Parameters with Categorical Marks
Description
This function computes the posterior of the parameters of a temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
Usage
mcmc_temporal_contmark(
times,
marks,
wshape,
t_max = max(times),
t_mis = NULL,
param_init = NULL,
mcmc_param = NULL,
branching = TRUE,
dist = "Weibull",
print = TRUE
)
Arguments
times |
- vector of arrival times |
marks |
- vector of continuous marks |
wshape |
- fixed weibull shape parameter |
t_max |
- maximum time value (default = max(times)) |
t_mis |
- |
param_init |
- list of parameters of initial guess (default = 'NULL', will start with MLE) |
mcmc_param |
- list of mcmc parameters |
branching |
- using branching structure in estimation (default = 'TRUE') |
dist |
- distribution for marks string (default = "Weibull") |
print |
- print progress (default = 'TRUE') |
Details
The default is to estimate the branching structure which is much more computationally efficient. The model will also account to missing data if t_mis
is provided.
Value
A List containing the mcmc samples (samps), branching structure ('y', if 'TRUE'), and missing data ('zsamps' if 't_mis' is not 'NULL') If 't_mis' is not 'NULL' the mcmc samples will contain 'n_missing', the number of missing points estimated
Point in polygon
Description
Determines if a point is in a polygon or on a polygon boundary
Usage
pip(x, y, poly)
Arguments
x |
- vector of x positions |
y |
- vector of y positions |
poly |
- matrix defining polygon ( |
Value
A list containing the x and y coordinates of the points inside the polygon @export
Calculate if points are in the polynomial
Description
Calculate if points are in the polynomial
Usage
ptinpoly(x, y, xp, yp, bb)
Arguments
x |
- vector of x coordinates |
y |
- vector of y coordinates |
xp |
- vector of x coordinates of polynomial |
yp |
- vector of y coordinates of polynomial |
bb |
- matrix of bounding box of polynomial |
Value
inout - vector of 1 if point is in polynomial and 0 if not
Simulate homogenous spatio-temporal hawkes model
Description
Simulate homogenous spatio-temporal hawkes model
Usage
simulate_hawkes_stpp(params, poly, t_region, d, history, seed = -1L)
Arguments
params |
- list containing params ( |
poly |
- matrix defining polygon ( |
t_region |
- vector of two elements describing time region (e.g., c(0,10)) |
d |
- generate parents on larger polygon by expanded observed polygon by d (default = R::qnorm(.95, 0, sig, 1, 0)) |
history |
- history of process (e.g., numeric()) |
seed |
- set random number seed (default=-1) |
Value
A DataFrame containing x
,y
,t
Simulate inhomogenous spatio-temporal hawkes model
Description
Simulate inhomogenous spatio-temporal hawkes model
Usage
simulate_hawkes_stpp_nonunif(params, poly, t_region, d, history, seed = -1L)
Arguments
params |
- list containing params ( |
poly |
- matrix defining polygon ( |
t_region |
- vector of two elements describing time region (e.g., c(0,10)) |
d |
- generate parents on larger polygon by expanded observed polygon by d (default = R::qnorm(.95, 0, sig, 1, 0)) |
history |
- history of process (e.g., numeric()) |
seed |
- set random number seed (default=-1) |
Value
A DataFrame containing x
,y
,t
Simulates a temporal Hawkes process with an exponential correlation function
Description
Simulates a temporal Hawkes process with an exponential correlation function
Usage
simulate_temporal(mu, alpha, beta, tt, times, seed = -1L)
Arguments
mu |
- background parameter |
alpha |
- |
beta |
- |
tt |
- vector of two elements defining time span (e.g., c(0,10)) |
times |
- history of previous times (e.g., numeric()) |
seed |
- value to seed random number generation (default = -1) |
Value
arrivals - vector of arrival times
Examples
times = simulate_temporal(.5,.1,.5,c(0,10),numeric())
MLE Estimation of Spatio-Temporal Hawkes Model Parameters
Description
Maximum likelihood estimation of the parameters of a spatio-temporal exponential decay Hawkes model.
Usage
stpp.mle(data, poly, t_max = max(data$t), initval = NA, print = TRUE)
Arguments
data |
- A DataFrame containing |
poly |
- a matrix defining the polygon |
t_max |
- maximum time value (default = max(times)) |
initval |
- vector of two elements describing missing time range (default = NA) |
print |
- print progress (default = TRUE) |
Value
A list containing the parameter values and likelihood value
MLE Estimation of Nonuniform Spatio-Temporal Hawkes Model Parameters
Description
Maximum likelihood estimation of the parameters of a spatio-temporal exponential decay Hawkes model.
Usage
stpp.mle.nonunif(data, poly, t_max = max(data$t), initval = NA, print = TRUE)
Arguments
data |
- A DataFrame containing |
poly |
- a matrix defining the polygon |
t_max |
- maximum time value (default = max(times)) |
initval |
- vector of two elements describing missing time range (default = NA) |
print |
- print progress (default = TRUE) |
Value
A list containing the parameter values and likelihood value
MLE Estimation of Temporal Hawkes Model Parameters with Categorical Marks
Description
Maximum likelihood estimation of the parameters of a temporal exponential decay Hawkes model
Usage
temporal.catmark.mle(t, marks, t_max = max(t), initval = NA, print = TRUE)
Arguments
t |
- vector of arrival times |
marks |
- vector of marks |
t_max |
- maximum time value (default = max(times)) |
initval |
- initial parameter values for likelihood optimization |
print |
- print progress (default = TRUE) |
Value
A list containing the parameter values and likelihood value
MLE Estimation of Temporal Hawkes Model Parameters
Description
Maximum likelihood estimation of the parameters of a temporal exponential decay Hawkes model
Usage
temporal.mle(t, t_max = max(t), initval = NA, print = TRUE)
Arguments
t |
- vector of arrival times |
t_max |
- maximum time value (default = max(times)) |
initval |
- vector of two elements describing missing time range (default = NA) |
print |
- print progress (default = TRUE) |
Value
A list containing the parameter values and likelihood value