MixedLMModel

class pyoptex.analysis.estimators.sams.models.mixed_lm_model.MixedLMModel(*args, V=None, **kwargs)[source]

A Mixed linear model for use with the SAMS algorithm which extends the OLSModel.

The data (X) and output variable (y) are adjusted to an OLS model based on the estimation of the observation covariance matrix specified by the groups and ratios.

If we assume that y is normally distributed with constant covariance matrix \(V\)

\[y \sim \mathcal{N}(X \beta, \sigma_\epsilon^2 V)\]

we can note that

\[V^{-1/2} y \sim \mathcal{N}(V^{-1/2} X \beta, \sigma_\epsilon^2 I_N)\]

Note

This assumes for computational purposes that the observation covariance matrix is accurately specified using the provided ratios. Once a model has been obtained, use REML to estimate the true variance ratios. Potentially rerun the SAMS algorithm with the updated variance ratios to validate that the same model is selected.

Attributes

Xnp.array(2d)

The encoded, normalized model matrix of the data. This data is corrected for the mixedlm approximation.

ynp.array(1d)

The output variable. This data is corrected for the mixedlm approximation.

forcednp.array(1d)

Any terms that must be included in the model.

modeNone or ‘weak’ or ‘strong’

The heredity model during sampling.

depnp.array(2d)

The dependency matrix of size (N, N) with N the number of terms in the encoded model (output from Y2X). Term i depends on term j if dep(i, j) = true.

ss_interceptfloat

The sum of squared residuals for a model with only the intercept. Recomputed to account for the mixedlm approximation.

__init__(*args, V=None, **kwargs)[source]

Creates the MixedLM model for SAMS.

Parameters

Xnp.array(2d)

The encoded, normalized model matrix of the data.

ynp.array(1d)

The output variable.

forcednp.array(1d)

Any terms that must be included in the model.

modeNone or ‘weak’ or ‘strong’

The heredity model during sampling.

depnp.array(2d)

The dependency matrix of size (N, N) with N the number of terms in the encoded model (output from Y2X). Term i depends on term j if dep(i, j) = true.

Vnp.array(2d)

The observation variance-covariance matrix.

Methods

MixedLMModel.fit(model)

Fits an OLS model

MixedLMModel.init(model)

Create a random model by sequential sampling.

MixedLMModel.mutate(model)

Mutate the model by removing atleast one term and replacing it.