log_likelihood¶
- LinearModel.log_likelihood(data: DataFrame) ndarray
Computes the log likelihood of observations
response_variablegiven 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 ofdata.
Raises¶
- TypeError
If
datais not an instance ofpandas.DataFrame.- ValueError
If
datais an emptypandas.DataFrame,if
response_variableis not a column ofdata,if
'mean'is not a column ofdata,if
'variance'is not a column ofdata.
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.