statsmodels.regression.mixed_linear_model.MixedLM¶
-
class
statsmodels.regression.mixed_linear_model.
MixedLM
(endog, exog, groups, exog_re=None, use_sqrt=True, missing='none', **kwargs)[source]¶ An object specifying a linear mixed effects model. Use the fit method to fit the model and obtain a results object.
Parameters: endog : 1d array-like
The dependent variable
exog : 2d array-like
A matrix of covariates used to determine the mean structure (the “fixed effects” covariates).
groups : 1d array-like
A vector of labels determining the groups – data from different groups are independent
exog_re : 2d array-like
A matrix of covariates used to determine the variance and covariance structure (the “random effects” covariates). If None, defaults to a random intercept for each group.
use_sqrt : bool
If True, optimization is carried out using the lower triangle of the square root of the random effects covariance matrix, otherwise it is carried out using the lower triangle of the random effects covariance matrix.
missing : string
The approach to missing data handling
Notes
The covariates in exog and exog_re may (but need not) partially or wholly overlap.
use_sqrt should almost always be set to True. The main use case for use_sqrt=False is when complicated patterns of fixed values in the covariance structure are set (using the free argument to fit) that cannot be expressed in terms of the Cholesky factor L.
Methods
EM
(fe_params, cov_re, scale[, niter_em, hist])Run the EM algorithm from a given starting point. Estep
(fe_params, cov_re, scale)The E-step of the EM algorithm. fit
([start_params, reml, niter_em, ...])Fit a linear mixed model to the data. fit_regularized
([start_params, method, ...])Fit a model in which the fixed effects parameters are penalized. from_formula
(formula, data[, re_formula, subset])Create a Model from a formula and dataframe. get_scale
(fe_params, cov_re)Returns the estimated error variance based on given estimates of the slopes and random effects covariance matrix. group_list
(array)Returns array split into subarrays corresponding to the grouping structure. hessian
(params)Returns the Hessian matrix of the profile log-likelihood. hessian_full
(params)Calculates the Hessian matrix for the mixed effects model with respect to the parameterization in which the covariance matrix is represented directly (without square-root transformation). hessian_sqrt
(params)Returns the Hessian matrix of the log-likelihood evaluated at a given point, calculated with respect to the parameterization in which the random effects covariance matrix is represented through its Cholesky square root. loglike
(params)Evaluate the (profile) log-likelihood of the linear mixed effects model. score
(params)Returns the score vector of the profile log-likelihood. score_full
(params)Calculates the score vector for the profiled log-likelihood of the mixed effects model with respect to the parameterization in which the random effects covariance matrix is represented in its full form (not using the Cholesky factor). score_sqrt
(params)Returns the score vector with respect to the parameterization in which the random effects covariance matrix is represented through its Cholesky square root. starting_values
(start_params)steepest_ascent
(params, n_iter)Take steepest ascent steps to increase the log-likelihood function. Attributes
endog_names
exog_names