shifted_beta_geometric_py
shifted_beta_geometric_py copied to clipboard
Different log-likelihood function
In the paper, the log likelihood is the sum of cancel rates times log probabilities, plus the end survived rate times final survivor likelihood. Should it therefore not be
def log_likelihood(alpha, beta, data, survivors=None):
if alpha <= 0 or beta <= 0:
return -1000
if survivors is None:
survivors = cancel_rates
probabilities = generate_probabilities(alpha, beta, len(data))
final_survivor_likelihood = survivor(probabilities, len(data) - 1)
return sum([s * np.log(probabilities[t]) for t, s in enumerate(data)]) + survivors[-1] * np.log(final_survivor_likelihood)