naginterfaces.library.correg.mixeff_reml¶
- naginterfaces.library.correg.mixeff_reml(dat, levels, yvid, cwid, fvid, fint, rvid, nvpr, vpr, rint, svid, gamma, lb, maxit=- 1, tol=0.0, io_manager=None)[source]¶
mixeff_reml
fits a linear mixed effects regression model using restricted maximum likelihood (REML).Deprecated since version 27.0.0.0:
mixeff_reml
is deprecated. Please uselmm_init()
followed bylmm_fit()
instead. See also the Replacement Calls document.For full information please refer to the NAG Library document for g02ja
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g02/g02jaf.html
- Parameters
- datfloat, array-like, shape
Array containing all of the data. For the th observation:
holds the dependent variable, ;
if , holds the case weights;
if , holds the subject variable.
The remaining columns hold the values of the independent variables.
- levelsint, array-like, shape
contains the number of levels associated with the th variable of the data matrix . If this variable is continuous or binary (i.e., only takes the values zero or one) then should be ; if the variable is discrete then is the number of levels associated with it and is assumed to take the values to , for .
- yvidint
The column of holding the dependent, , variable.
- cwidint
The column of holding the case weights.
If , no weights are used.
- fvidint, array-like, shape
The columns of the data matrix holding the fixed independent variables with holding the column number corresponding to the th fixed variable.
- fintint
Flag indicating whether a fixed intercept is included ().
- rvidint, array-like, shape
The columns of the data matrix holding the random independent variables with holding the column number corresponding to the th random variable.
- nvprint
If and , is the number of variance components being , (), else .
If , is not referenced.
- vprint, array-like, shape
holds a flag indicating the variance of the th random variable. The variance of the th random variable is , where if and and otherwise. Random variables with the same value of are assumed to be taken from the same distribution.
- rintint
Flag indicating whether a random intercept is included ().
If , is not referenced.
- svidint
The column of holding the subject variable.
If , no subject variable is used.
Specifying a subject variable is equivalent to specifying the interaction between that variable and all of the random-effects.
Letting the notation denote the interaction between variables and , fitting a model with , random-effects and subject variable is equivalent to fitting a model with random-effects and no subject variable.
If the model is equivalent to fitting and no subject variable.
- gammafloat, array-like, shape
Holds the initial values of the variance components, , with the initial value for , for . If and , , else .
If , the remaining elements of are ignored and the initial values for the variance components are estimated from the data using MIVQUE0.
- lbint
The size of the array .
- maxitint, optional
The maximum number of iterations.
If , the default value of is used.
If , the parameter estimates and corresponding standard errors are calculated based on the value of supplied in .
- tolfloat, optional
The tolerance used to assess convergence.
If , the default value of is used, where is the machine precision.
- io_managerFileObjManager, optional
Manager for I/O in this routine.
- Returns
- gammafloat, ndarray, shape
, for , holds the final estimate of and holds the final estimate for .
- nffint
The number of fixed effects estimated (i.e., the number of columns, , in the design matrix ).
- nrfint
The number of random effects estimated (i.e., the number of columns, , in the design matrix ).
- dfint
The degrees of freedom.
- remlfloat
where is the log of the restricted maximum likelihood calculated at , the estimated variance components returned in .
- bfloat, ndarray, shape
The parameter estimates, , with the first elements of containing the fixed effect parameter estimates, and the next elements of containing the random effect parameter estimates, .
Fixed effects
If , contains the estimate of the fixed intercept.
Let denote the number of levels associated with the th fixed variable, that is .
Define
if , else if , ;
, .
Then for :
if , contains the parameter estimate for the th level of the th fixed variable, for ;
if , contains the parameter estimate for the th fixed variable.
Random effects
Redefining to denote the number of levels associated with the th random variable, that is .
Define
if , else if , ;
, .
Then for :
if ,
if , contains the parameter estimate for the th level of the th random variable, for ;
if , contains the parameter estimate for the th random variable;
if ,
let denote the number of levels associated with the subject variable, that is ;
if , contains the parameter estimate for the interaction between the th level of the subject variable and the th level of the th random variable, for , for ;
if , contains the parameter estimate for the interaction between the th level of the subject variable and the th random variable, for ;
if , contains the estimate of the random intercept.
- sefloat, ndarray, shape
The standard errors of the parameter estimates given in .
- warnint
Is set to if a variance component was estimated to be a negative value during the fitting process. Otherwise is set to .
If , the negative estimate is set to zero and the estimation process allowed to continue.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: number of observations with nonzero weights must be greater than one.
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, and .
Constraint: and .
- (errno )
On entry, and .
Constraint: and ( or ).
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, and .
Constraint: and any supplied weights must be .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, too small: .
- (errno )
On entry, , for at least one .
- (errno )
On entry, .
Constraint: , for all .
- (errno )
On entry, .
Constraint: , for all .
- (errno )
On entry, .
Constraint: , for all .
- (errno )
On entry, invalid data: categorical variable with value greater than that specified in .
- (errno )
On entry, , for at least one .
- (errno )
Degrees of freedom : .
- (errno )
Routine failed to converge to specified tolerance: .
- (errno )
Routine failed to converge in iterations: .
- Notes
mixeff_reml
fits a model of the form:where
is a vector of observations on the dependent variable,
is a known design matrix for the fixed independent variables,
is a vector of length of unknown fixed effects,
is a known design matrix for the random independent variables,
is a vector of length of unknown random effects,
and
is a vector of length of unknown random errors.
Both and are assumed to have a Gaussian distribution with expectation zero and
where , is the identity matrix and is a diagonal matrix. It is assumed that the random variables, , can be subdivided into groups with each group being identically distributed with expectations zero and variance . The diagonal elements of matrix , therefore, take one of the values , depending on which group the associated random variable belongs to.
The model, therefore, contains three sets of unknowns, the fixed effects, , the random effects and a vector of variance components, , where . Rather than working directly with ,
mixeff_reml
uses an iterative process to estimate . Due to the iterative nature of the estimation a set of initial values, , for is required.mixeff_reml
allows these initial values either to be supplied by you or calculated from the data using the minimum variance quadratic unbiased estimators (MIVQUE0) suggested by Rao (1972).mixeff_reml
fits the model using a quasi-Newton algorithm to maximize the restricted log-likelihood function:where
Once the final estimates for have been obtained, the value of is given by:
Case weights, , can be incorporated into the model by replacing and with and respectively, for a diagonal weight matrix .
The log-likelihood, , is calculated using the sweep algorithm detailed in Wolfinger et al. (1994).
- References
Goodnight, J H, 1979, A tutorial on the SWEEP operator, The American Statistician (33(3)), 149–158
Harville, D A, 1977, Maximum likelihood approaches to variance component estimation and to related problems, JASA (72), 320–340
Rao, C R, 1972, Estimation of variance and covariance components in a linear model, J. Am. Stat. Assoc. (67), 112–115
Stroup, W W, 1989, Predictable functions and prediction space in the mixed model procedure, Applications of Mixed Models in Agriculture and Related Disciplines (Southern Cooperative Series Bulletin No. 343), 39–48
Wolfinger, R, Tobias, R and Sall, J, 1994, Computing Gaussian likelihoods and their derivatives for general linear mixed models, SIAM Sci. Statist. Comput. (15), 1294–1310