Skip to content

Commit b185a76

Browse files
committed
Types, constructors and simulation
Everything else still not implemented.
1 parent 8d0525a commit b185a76

File tree

11 files changed

+319
-194
lines changed

11 files changed

+319
-194
lines changed

docs/src/api.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ MultivariatePoissonProcessPrior
104104
HawkesProcess
105105
```
106106

107+
### Univariate
108+
109+
```@docs
110+
UnivariateHawkesProcess
111+
UnmarkedUnivariateHawkesProcess
112+
```
113+
114+
### Multivariate
115+
116+
```@docs
117+
MultivariateHawkesProcess
118+
```
119+
107120
## Index
108121

109122
```@index

src/PointProcesses.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ module PointProcesses
1010
using DensityInterface: DensityInterface, HasDensity, densityof, logdensityof
1111
using Distributions: Distributions, UnivariateDistribution, MultivariateDistribution
1212
using Distributions: Categorical, Exponential, Poisson, Uniform, Dirac
13-
using Distributions: fit, suffstats, probs, mean
14-
using LinearAlgebra: dot
13+
using Distributions: fit, suffstats, probs, mean, support
14+
using LinearAlgebra: dot, diagm
1515
using Random: rand
1616
using Random: AbstractRNG, default_rng
1717
using StatsAPI: StatsAPI, fit
@@ -46,10 +46,15 @@ export simulate_ogata, simulate
4646

4747
## Models
4848

49+
### Poisson processes
4950
export PoissonProcess
5051
export UnivariatePoissonProcess
5152
export MultivariatePoissonProcess, MultivariatePoissonProcessPrior
53+
54+
### Hawkes processes
5255
export HawkesProcess
56+
export UnivariateHawkesProcess, UnmarkedUnivariateHawkesProcess
57+
export MultivariateHawkesProcess
5358

5459
# Includes
5560

@@ -65,5 +70,9 @@ include("poisson/fit.jl")
6570
include("poisson/simulation.jl")
6671

6772
include("hawkes/hawkes_process.jl")
73+
include("hawkes/simulation.jl")
74+
include("hawkes/intensity.jl")
75+
include("hawkes/fit.jl")
76+
include("hawkes/time_change.jl")
6877

6978
end

src/hawkes/fit.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
StatsAPI.fit(rng, ::Type{HawkesProcess{T}}, h::History; step_tol::Float64 = 1e-6, max_iter::Int = 1000) where {T<:Real}
2+
StatsAPI.fit(rng, ::Type{UnmarkedUnivariateHawkesProcess{T}}, h::History; step_tol::Float64 = 1e-6, max_iter::Int = 1000) where {T<:Real}
33
44
Expectation-Maximization algorithm from [E. Lewis, G. Mohler (2011)](https://arxiv.org/pdf/1801.08273)).
55
The relevant calculations are in page 4, equations 6-13.
@@ -29,11 +29,11 @@ therefore, the interval of the process is transformed from T to N. Also, in equa
2929
3030
"""
3131
function StatsAPI.fit(
32-
::Type{UnivariateHawkesProcess{T}},
32+
::Type{<:UnmarkedUnivariateHawkesProcess{T}},
3333
h::History;
3434
step_tol::Float64=1e-6,
3535
max_iter::Int=1000,
36-
rng::AbstractRNG=default_rng()
36+
rng::AbstractRNG=default_rng(),
3737
) where {T<:Real}
3838
n = nb_events(h)
3939
n == 0 && return HawkesProcess(zero(T), zero(T), zero(T))
@@ -100,8 +100,10 @@ function StatsAPI.fit(
100100
return HawkesProcess* (n / tmax), ψ * ω * (n / tmax), ω * (n / tmax))
101101
end
102102

103-
# # Type parameter for `HawkesProcess` was NOT explicitly provided
104-
# function StatsAPI.fit(HP::Type{HawkesProcess}, h::History{H,M}; kwargs...) where {H<:Real,M}
105-
# T = promote_type(Float64, H)
106-
# return fit(HP{T}, h; kwargs...)
107-
# end
103+
# Type parameter for `HawkesProcess` was NOT explicitly provided
104+
function StatsAPI.fit(
105+
HP::Type{UnmarkedUnivariateHawkesProcess}, h::History{H,M}; kwargs...
106+
) where {H<:Real,M}
107+
T = promote_type(Float64, H)
108+
return fit(HP{T}, h; kwargs...)
109+
end

0 commit comments

Comments
 (0)