statsmodels.regression.mixed_linear_model.MixedLM.fit

MixedLM.fit(start_params=None, reml=True, niter_sa=0, do_cg=True, fe_pen=None, cov_pen=None, free=None, full_output=False, method='bfgs', **kwargs)[source]

Fit a linear mixed model to the data.

Parameters:

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.

reml : bool

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

cov_pen : CovariancePenalty object

A penalty for the random effects covariance matrix

fe_pen : Penalty object

A penalty on the fixed effects

free : MixedLMParams 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).

full_output : bool

If true, attach iteration history to results

method : string

Optimization method.

Returns:

A MixedLMResults instance.