X-DataInitiative / tick

Module for statistical learning, with a particular emphasis on time-dependent modelling
https://x-datainitiative.github.io/tick/
BSD 3-Clause "New" or "Revised" License
484 stars 105 forks source link

Negative Log Likelihood/Loss Calculation : Error in the formula #449

Open dharmash opened 4 years ago

dharmash commented 4 years ago

There seems to be an error in the following function in: https://github.com/X-DataInitiative/tick/blob/master/lib/cpp/hawkes/model/base/model_hawkes_loglik_single.cpp

double ModelHawkesLogLikSingle::loss_dim_i(const ulong i, const ArrayDouble &coeffs)

Ln 126 reads: double loss = -end_time;

This should instead be: double loss = 0.0;

Think of the case where the infectivity/adjacency matrix is zero everywhere. This is the case of a mutually independent multi-dimensional Poisson process. When you take your above function as-is, this adds an erroneous extra sum (= -1 number of dimensions end_time) to the to the negative-log-likelihood. The negative-log-likelihood for this case is simply: mu(i)T - N(i) log(mu(i)), summed over each dimension i. There should' be any -T that is added to each dimension, which is what is happening at the moment.

Thanks, and hope you review and correct this.