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=None, **fit_kwargs)[source]

Fit a linear mixed model to the data.

Parameters:
start_paramsarray_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.

remlbool

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

niter_saint

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

cov_penCovariancePenalty object

A penalty for the random effects covariance matrix

do_cgbool, 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 corresponding 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_outputbool

If true, attach iteration history to results

methodstr

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

**fit_kwargs

Additional keyword arguments passed to fit.

Returns:
A MixedLMResults instance.

Last update: Mar 18, 2024