class statsmodels.base.model.GenericLikelihoodModel(endog, exog=None, loglike=None, score=None, hessian=None, missing='none', extra_params_names=None, **kwds)[source]

Allows the fitting of any likelihood function via maximum likelihood.

A subclass needs to specify at least the log-likelihood If the log-likelihood is specified for each observation, then results that require the Jacobian will be available. (The other case is not tested yet.)


Optimization methods that require only a likelihood function are ‘nm’ and ‘powell’

Optimization methods that require a likelihood function and a score/gradient are ‘bfgs’, ‘cg’, and ‘ncg’. A function to compute the Hessian is optional for ‘ncg’.

Optimization method that require a likelihood function, a score/gradient, and a Hessian is ‘newton’

If they are not overwritten by a subclass, then numerical gradient, Jacobian and Hessian of the log-likelihood are caclulated by numerical forward differentiation. This might results in some cases in precision problems, and the Hessian might not be positive definite. Even if the Hessian is not positive definite the covariance matrix of the parameter estimates based on the outer product of the Jacobian might still be valid.


see also subclasses in directory miscmodels

import statsmodels.api as sm data = sm.datasets.spector.load(as_pandas=False) data.exog = sm.add_constant(data.exog) # in this dir from model import GenericLikelihoodModel probit_mod = sm.Probit(data.endog, data.exog) probit_res = loglike = probit_mod.loglike score = probit_mod.score mod = GenericLikelihoodModel(data.endog, data.exog, loglike, score) res =”nm”, maxiter = 500) import numpy as np np.allclose(res.params, probit_res.params)


Names of endogenous variables


Names of exogenous variables



expand to full parameter array when some parameters are fixed

fit([start_params, method, maxiter, …])

Fit the model using maximum likelihood.

from_formula(formula, data[, subset, drop_cols])

Create a Model from a formula and dataframe.


Hessian of log-likelihood evaluated at params

hessian_factor(params[, scale, observed])

Weights for calculating Hessian


Fisher information matrix of model


Initialize (possibly re-initialize) a Model instance.


Log-likelihood of model at params


Log-likelihood of individual observations at params


Negative log-likelihood of model at params

predict(params[, exog])

After a model has been fit predict returns the fitted values.


Reduce parameters


Gradient of log-likelihood evaluated at params

score_obs(params, **kwds)

Jacobian/Gradient of log-likelihood evaluated at params for each observation.