naginterfaces.library.correg.mixeff_​hier_​init

naginterfaces.library.correg.mixeff_hier_init(dat, levels, y, fixed, rndm, wt=None)[source]

mixeff_hier_init preprocesses a dataset prior to fitting a linear mixed effects regression model of the following form via either mixeff_hier_reml() or mixeff_hier_ml().

Deprecated since version 27.0.0.0: mixeff_hier_init is deprecated. Please use lmm_init() instead. See also the Replacement Calls document.

For full information please refer to the NAG Library document for g02jc

https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/g02/g02jcf.html

Parameters
datfloat, array-like, shape

A matrix of data, with holding the th observation on the th variable. The two design matrices and are constructed from and the information given in (for ) and (for ).

levelsint, array-like, shape

contains the number of levels associated with the th variable held in .

If the th variable is continuous or binary (i.e., only takes the values zero or one), then must be set to .

Otherwise the th variable is assumed to take an integer value between and , (i.e., the th variable is discrete with levels).

yfloat, array-like, shape

, the vector of observations on the dependent variable.

fixedint, array-like, shape

Defines the structure of the fixed effects design matrix, .

The number of variables, , to include as fixed effects (not including the intercept if present).

The fixed intercept flag which must contain if a fixed intercept is to be included and otherwise.

The column of holding the th fixed variable, for .

See Construction of the fixed effects design matrix, X for more details on the construction of .

rndmint, array-like, shape

defines the structure of the random effects design matrix, . The th column of defines a block of columns in the design matrix .

The number of variables, , to include as random effects in the th block (not including the random intercept if present).

The random intercept flag which must contain if block includes a random intercept and otherwise.

The column of holding the th random variable in the th block, for .

The number of subject variables, , for the th block. The subject variables define the nesting structure for this block.

The column of holding the th subject variable in the th block, for .

See Construction of random effects design matrix, Z for more details on the construction of .

wtNone or float, array-like, shape , optional

Note: the required length for this argument is determined as follows: if : ; otherwise: .

Optionally, the weights to be used in the weighted regression.

If , the th observation is not included in the model, in which case the effective number of observations is the number of observations with nonzero weights.

If weights are not provided then must be set to None and the effective number of observations is .

Returns
nffint

, the number of fixed effects estimated, i.e., the number of columns in the design matrix .

nlsvint

The number of levels for the overall subject variable (see Construction of random effects design matrix, Z for a description of what this means). If there is no overall subject variable, .

nrfint

The number of random effects estimated in each of the overall subject blocks. The number of columns in the design matrix is given by .

commdict, communication object

Communication structure.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, variable of observation is less than or greater than : , , value , .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, number of fixed parameters, is less than zero.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, number of random parameters for random statement is less than : , number of parameters .

(errno )

On entry, more fixed factors than observations, .

Constraint: .

(errno )

On entry, no observations due to zero weights.

(errno )

On entry, invalid value for fixed intercept flag: value .

(errno )

On entry, invalid value for random intercept flag for random statement : , value .

(errno )

On entry, index of fixed variable is less than or greater than : , index and .

(errno )

On entry, must be at least one parameter, or an intercept in each random statement : .

(errno )

On entry, index of random variable in random statement is less than or greater than : , , index and .

(errno )

On entry, number of subject parameters for random statement is less than : , number of parameters .

(errno )

On entry, nesting variable in random statement has one level: , .

Notes

mixeff_hier_init must be called prior to fitting a linear mixed effects regression model with either mixeff_hier_reml() or mixeff_hier_ml().

The model fitting functions mixeff_hier_reml() and mixeff_hier_ml() fit a model of the following form:

where

is a vector of observations on the dependent variable,

is an design matrix of fixed independent variables,

is a vector of unknown fixed effects,

is an design matrix of random independent variables,

is a vector of length of unknown random effects,

is a vector of length of unknown random errors,

and and are Normally distributed with expectation zero and variance/covariance matrix defined by

where , is the identity matrix and is a diagonal matrix.

Case weights can be incorporated into the model by replacing and with and respectively where is a diagonal weight matrix.