Package 'stpphawkes'

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

Help Index


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 WW, 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 (NN x 22)

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 xx,yy,tt

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 xx,yy,tt

poly

- matrix defining polygon (NN x 22)

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 DataFrame containing the mcmc samples


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 xx,yy,tt

poly

- matrix defining polygon (NN x 22)

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 DataFrame containing the mcmc samples


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

- 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)

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 DataFrame containing the mcmc samples

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

- 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)

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 DataFrame containing the mcmc samples


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

- 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)

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 DataFrame containing the mcmc samples


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 (NN x 22)

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 (μ\mu, aa, bb, σ\sigma)

poly

- matrix defining polygon (NN x 22)

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 xx,yy,tt


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 (μ\mu, aa, bb, σ\sigma,μx\mu x, μy\mu y, σx\sigma x, σy\sigma y )

poly

- matrix defining polygon (NN x 22)

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 xx,yy,tt


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

- α\alpha parameter

beta

- β\beta parameter

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 xx,yy, and tt

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 xx,yy, and tt

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


Marked Hawkes Process with Missing Data

Description

A library for estimation of spatio-temporal Hawkes process parameters with missing data support

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.


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