CLG.logLikelihood

CLG.logLikelihood(data)

Return the log-likelihood of the data.

Parameters:

data (str | pandas.DataFrame) – The data: the name of a csv file, or a dataframe, with one column per variable of the CLG.

Returns:

The log-likelihood of the data for the CLG (natural logarithm): the sum, over the records and the variables, of the log-density of each variable given its parents.

Return type:

float

Example

import pyagrum as gum
import pyagrum.clg as gclg

gum.initRandom(42)  # the draws of pyagrum.clg come from the random generator of aGrUM
clg = gclg.SEM.toclg("""
A = 2[1]
B = 1 + 0.5A[2]
C = 3 + B[1]
""")
gclg.ForwardSampling(clg).makeSample(500).tocsv("data.csv")
ll = clg.logLikelihood("data.csv")
bool(ll < 0)  # a log-likelihood of continuous data is not bounded, but here negative
# True

Class

CLG