Title: | Missing Data for Marked Hawkes Process |
---|---|
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>). |
Authors: | J. Derek Tucker [aut, cre], Lyndsay Shand [aut], Stephen Rowe [aut], John Lewis [aut] |
Maintainer: | J. Derek Tucker <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.1 |
Built: | 2024-11-24 06:55:38 UTC |
Source: | CRAN |
Calculate area of polynomial
areapl(poly)
areapl(poly)
poly |
- matrix describing polynomial |
W - area of polynomial
This function simulates a homogenous space-time Poisson process on , defined by polygon
homog.STPP( mu, poly, t.region, xfrac = 0.1, yfrac = 0.1, remove = FALSE, checkpoly = TRUE, showplot = FALSE )
homog.STPP( mu, poly, t.region, xfrac = 0.1, yfrac = 0.1, remove = FALSE, checkpoly = TRUE, showplot = FALSE )
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) |
A DataFrame containing ,
,
out = homog.STPP(0.5,matrix(c(0,0,1,1,0,1,1,0),ncol=2),c(0,10))
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
intensity_temporal(mu, alpha, beta, times, evalpt)
intensity_temporal(mu, alpha, beta, times, evalpt)
mu |
- background parameter |
alpha |
- alpha parameter |
beta |
- beta parameter |
times |
- history of previous times |
evalpt |
- point to evaluate |
lambda - intensity at evalpt
This function computes the posterior of a spatio-temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
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 )
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 )
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) |
The default is to estimate the branching structure.
The model will also account to missing data if t_mis
is provided.
A DataFrame containing the mcmc samples
This function computes the posterior of a spatio-temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
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 )
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 )
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) |
The default is to estimate the branching structure.
The model will also account to missing data if t_mis
is provided.
A DataFrame containing the mcmc samples
This function computes the posterior of the parameters of a temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
mcmc_temporal( times, t_max = max(times), t_mis = NULL, param_init = NULL, mcmc_param = NULL, branching = TRUE, print = TRUE )
mcmc_temporal( times, t_max = max(times), t_mis = NULL, param_init = NULL, mcmc_param = NULL, branching = TRUE, print = TRUE )
times |
- vector of arrival times |
t_max |
- maximum time value (default = max(times)) |
t_mis |
- mx2 matrix, mth row contains two elements describing the mth 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) |
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.
A DataFrame containing the mcmc samples
times = simulate_temporal(.5,.1,.5,c(0,10),numeric()) out = mcmc_temporal(times)
times = simulate_temporal(.5,.1,.5,c(0,10),numeric()) out = mcmc_temporal(times)
This function computes the posterior of the parameters of a temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
mcmc_temporal_catmark( times, marks, t_max = max(times), t_mis = NULL, param_init = NULL, mcmc_param = NULL, branching = TRUE, print = TRUE )
mcmc_temporal_catmark( times, marks, t_max = max(times), t_mis = NULL, param_init = NULL, mcmc_param = NULL, branching = TRUE, print = TRUE )
times |
- vector of arrival times |
marks |
- vector of marks |
t_max |
- maximum time value (default = max(times)) |
t_mis |
- mx2 matrix, mth row contains two elements describing the mth 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) |
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.
A DataFrame containing the mcmc samples
This function computes the posterior of the parameters of a temporal exponential decay Hawkes model using Metropolis-with-in-Gibbs sampling.
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 )
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 )
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 |
- mx2 matrix, mth row contains two elements describing the mth 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) |
dist |
- distribution for marks string (default = "Weibull") |
print |
- print progress (default = TRUE) |
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.
A DataFrame containing the mcmc samples
Determines if a point is in a polygon or on a polygon boundary
pip(x, y, poly)
pip(x, y, poly)
x |
- vector of x positions |
y |
- vector of y positions |
poly |
- matrix defining polygon ( |
A list containing the x and y coordinates of the points inside the polygon @export
Calculate if points are in the polynomial
ptinpoly(x, y, xp, yp, bb)
ptinpoly(x, y, xp, yp, bb)
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 |
inout - vector of 1 if point is in polynomial and 0 if not
Simulate homogenous spatio-temporal hawkes model
simulate_hawkes_stpp(params, poly, t_region, d, history, seed = -1L)
simulate_hawkes_stpp(params, poly, t_region, d, history, seed = -1L)
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) |
A DataFrame containing ,
,
Simulate inhomogenous spatio-temporal hawkes model
simulate_hawkes_stpp_nonunif(params, poly, t_region, d, history, seed = -1L)
simulate_hawkes_stpp_nonunif(params, poly, t_region, d, history, seed = -1L)
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) |
A DataFrame containing ,
,
Simulates a temporal Hawkes process with an exponential correlation function
simulate_temporal(mu, alpha, beta, tt, times, seed = -1L)
simulate_temporal(mu, alpha, beta, tt, times, seed = -1L)
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) |
arrivals - vector of arrival times
times = simulate_temporal(.5,.1,.5,c(0,10),numeric())
times = simulate_temporal(.5,.1,.5,c(0,10),numeric())
Maximum likelihood estimation of the parameters of a spatio-temporal exponential decay Hawkes model.
stpp.mle(data, poly, t_max = max(data$t), initval = NA, print = TRUE)
stpp.mle(data, poly, t_max = max(data$t), initval = NA, print = TRUE)
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) |
A list containing the parameter values and likelihood value
Maximum likelihood estimation of the parameters of a spatio-temporal exponential decay Hawkes model.
stpp.mle.nonunif(data, poly, t_max = max(data$t), initval = NA, print = TRUE)
stpp.mle.nonunif(data, poly, t_max = max(data$t), initval = NA, print = TRUE)
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) |
A list containing the parameter values and likelihood value
A library for estimation of spatio-temporal Hawkes process parameters with missing data support
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.
Maximum likelihood estimation of the parameters of a temporal exponential decay Hawkes model
temporal.catmark.mle(t, marks, t_max = max(t), initval = NA, print = TRUE)
temporal.catmark.mle(t, marks, t_max = max(t), initval = NA, print = TRUE)
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) |
A list containing the parameter values and likelihood value
Maximum likelihood estimation of the parameters of a temporal exponential decay Hawkes model
temporal.mle(t, t_max = max(t), initval = NA, print = TRUE)
temporal.mle(t, t_max = max(t), initval = NA, print = TRUE)
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) |
A list containing the parameter values and likelihood value