method, reml=True, niter_sa=0, do_cg=True, fe_pen=None, cov_pen=None, free=None, full_output=False, method=None, **kwargs)[source]

Fit a linear mixed model to the data.

start_params: array-like or MixedLMParams

Starting values for the profile log-likelihood. If not a MixedLMParams instance, this should be an array containing the packed parameters for the profile log-likelihood, including the fixed effects parameters.


If true, fit according to the REML likelihood, else fit the standard likelihood using ML.

niter_sa :

Currently this argument is ignored and has no effect on the results.

cov_penCovariancePenalty object

A penalty for the random effects covariance matrix

do_cgboolean, defaults to True

If False, the optimization is skipped and a results object at the given (or default) starting values is returned.

fe_penPenalty object

A penalty on the fixed effects

freeMixedLMParams object

If not None, this is a mask that allows parameters to be held fixed at specified values. A 1 indicates that the correspondinig parameter is estimated, a 0 indicates that it is fixed at its starting value. Setting the cov_re component to the identity matrix fits a model with independent random effects. Note that some optimization methods do not respect this constraint (bfgs and lbfgs both work).


If true, attach iteration history to results


Optimization method. Can be a scipy.optimize method name, or a list of such names to be tried in sequence.

A MixedLMResults instance.