Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Seondong opened this issue Mar 23, 2019 · 0 comments
Open

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

Seondong opened this issue Mar 23, 2019 · 0 comments

Comments

@Seondong
Copy link

Seondong commented Mar 23, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant