fit_mixedlm

pyoptex.analysis.utils.fit.fit_mixedlm(X, y, groups)[source]

Wrapper to fit a statsmodels Mixed LM model. It includes the following additional attributes required for a more synchronized output between OLS and Mixed LM.

  • rsquared : The simple r2_score of the fit.

  • rsquared_adj : The adjust r2 score according to r2_adj.

Parameters

Xnp.array(2d)

The normalized, encoded model matrix of the data.

ynp.array(1d)

The output variable

groupsnp.array(2d)

The 2d array of the groups for the random effects of size (g, N), with g the number of random effects and N the number of runs. Each row is an integer array with values from 0 until the total number of groups for that random effect. For example [0, 0, 1, 1] indicates that the first two runs are correlated, and the last two.

Returns

fitstatsmodels.regression.mixed_linear_model.MixedLMResults

The statsmodels Mixed LM results with some additional attributes.