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

dixon_coles_correlation_term can return nan values #6

Open
jack89roberts opened this issue Jul 18, 2021 · 3 comments
Open

dixon_coles_correlation_term can return nan values #6

jack89roberts opened this issue Jul 18, 2021 · 3 comments

Comments

@jack89roberts
Copy link
Collaborator

Example data and script that gives me a few nans below. Was generated with a model using one and a half seasons of data and predicting the probability of Man City 0 - Aston Villa 1:

inputs.pkl.zip

import pickle
from bpl._util import dixon_coles_correlation_term
import numpy as np
import jax.numpy as jnp

with open("inputs.pkl", "rb") as f:
    inputs = pickle.load(f)

corr_term = dixon_coles_correlation_term(
    inputs["home_goals"],
    inputs["away_goals"],
    jnp.array(inputs["expected_home_goals"]),
    jnp.array(inputs["expected_away_goals"]),
    jnp.array(inputs["corr_coef"]),
)
print(np.any(np.isnan(corr_term)))
@jack89roberts
Copy link
Collaborator Author

jack89roberts commented Aug 6, 2021

After investigating a bit more. The Dixon-Coles paper has the constraint:

max(- 1/lambda, - 1/mu) < rho < min(1 / (lambda * mu), 1)

This constraint is violated occasionally, in particular at the lower end. It looks to me like bpl has much narrower priors on rho than bpl-next? Maybe that's the issue?

@jack89roberts
Copy link
Collaborator Author

jack89roberts commented Aug 6, 2021

More likely for teams with only a small number of match results in the input data (e.g. newly promoted teams) / when using less data in general. Quickly played with priors but didn't seem to make much difference.

@jack89roberts
Copy link
Collaborator Author

#7 just sidesteps the problem by setting negative arguments to jnp.log to 0.

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