Skip to content

Need to add 'horizon' for EM method in MHP.py. #3

Description

@Seondong

Hi Steve, I have been using hawkes library, and I found an issue regarding an availability of time horizon in EM method.

For generating a sequence, we need to give a horizon parameter (e.g., P.generate_seq(10)), so that we can obtain the simulated data up to t=10. However, the EM method does not get any information from the last event, which does not produce the right parameter estimation.

In below example, I share a case when the event happens in the early beginning of the time horizon, thus the EM method fails by estimating parameter by only using the information until the last event.

### A single case 
m = np.array([0.1])
a = np.array([[0]])
w = 1

P = MHP(mu=m, alpha=a, omega=w)
### In this example, an event appeared in a very early stage of the time horizon.
P.generate_seq(10)

Out[1]: array([[1.69135373, 0. ]])

# Since the input of the EM method is only P.data, 
# it does not have any information that no event happens from [1.69, 10]
# So the predicted 'mu' value is very big (0.59124238 = 1/1.69135373)
P.EM(a, m, w, verbose=False)

Out[2]: (array([[0.]]), array([0.59124238]))


Is there any walkaround that I can put extra time_horizon parameter to make a right parameter estimation? I think the right solution might look like this.

# Add or have a time horizon in P, so that EM algorithm can utilize a timeline after the last event.
P.time_horizon = [10]
P.EM(a, m, w, verbose=False)    # or P.EM(a, m, w, time_horizon=[10], verbose=False)

Out[2]: (array([[0.]]), array([0.1]))


Thanks for effort on publicizing your work, I think your library is much more intuitive than tick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions