log_likelihood

LinearModel.log_likelihood(data: DataFrame) ndarray

Computes the log likelihood of observations response_variable given a model 'mean' and 'variance'.

Parameters

data: pandas.DataFrame

Data to use for log likelihood computation. It cannot be empty. It must contain columns response_variable, 'mean' and 'variance'.

Returns

numpy.ndarray

Array of computed log likelihood. It has the same length of data. Each element is a log likelihood computation of each row of data.

Raises

TypeError

If data is not an instance of pandas.DataFrame.

ValueError
  • If data is an empty pandas.DataFrame,

  • if response_variable is not a column of data,

  • if 'mean' is not a column of data,

  • if 'variance' is not a column of data.

Notes

The log likelihood is computed as the log of the normal distribution probability density function:

\[l(y) = - \frac{1}{2} \log{2 \pi \sigma^2} - \frac{1}{2} \frac{\left(y - \mu \right)^2}{\sigma^2}\]

where \(\mu\) is the 'mean' column and \(\sigma^2\) is the 'variance' column.