likelihood

LinearModel.likelihood(data: DataFrame) ndarray

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

Parameters

data: pandas.DataFrame

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

Returns

numpy.ndarray

Array of computed likelihood. It has the same length of data. Each element is a 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 likelihood is computed with the normal distribution probability density function:

\[L(y) = \frac{1}{\sqrt{2 \pi \sigma^2}} \exp{- \frac{\left(y - \mu \right)^2}{2 \sigma^2}}\]

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