Package 'MMeM'

Title: Multivariate Mixed Effects Model
Description: Analyzing data under multivariate mixed effects model using multivariate REML and multivariate Henderson3 methods. See Meyer (1985) <doi:10.2307/2530651> and Wesolowska Janczarek (1984) <doi:10.1002/bimj.4710260613>.
Authors: Luyao Peng [aut, cre], Rui Yang [aut]
Maintainer: Luyao Peng <[email protected]>
License: GPL-3
Version: 0.1.1
Built: 2025-02-23 03:30:47 UTC
Source: https://github.com/pengluyaoyao/mmem

Help Index


MMeM: Estimating the variance covariance components of the multivariate mixed effects model

Description

This package analyzes data under multivariate mixed effects model using multivariate REML and multivariate Henderson3 methods. Currently, it only supports multivariate mixed effects model with one fixed effects and one random effects and two response variates. See Meyer (1985) <doi:10.2307/2530651> and Wesolowska Janczarek (1984) <doi:10.1002/bimj.4710260613>.

Author(s)

Luyao Peng [email protected]

Rui Yang [email protected]

See Also

Useful links:


Multivariate Henderson3 method

Description

Multivariate Henderson3 method

Usage

MMeM_henderson3(fml, data, factor_X)

Arguments

fml

two-sided linear formula object describing both the fixed-effects and random-effects parts of the model, with the response on the left of a ~ operator. For univariate response, put variable name directly; for multivariate responses combine variables using concatenate operator, for example, for bivariate responses, c(var1, var2). The predictor terms are separated by + operators, on the right. Random-effects terms are distinguished by vertical bars '|' separating expressions for design matrices from grouping factors.

data

data frame containing the variables named in formula.

factor_X

(logical) indicating whether predictor is a factor or continuous. By default is TRUE

Value

The function returns a list with the following objects:

  • T.estimates is the estimated variance covariance components (T.estimates) of the variance covariance matrix of the block random effects with corresponding sampling variances (T.variance)

  • E.estimates is the estimated variance covariance components (E.estimates) of the variance covariance matrix of the residuals with corresponding sampling variances (E.variance)

References

Wesolowska Janczarek, M. T. "Estimation of covariance matrices in unbalanced random and mixed multivariate models." Biometrical journal 26.6 (1984): 665,674.

Examples

data(simdata)
results_henderson <- MMeM_henderson3(fml = c(V1,V2) ~ X_vec + (1|Z_vec),
data = simdata, factor_X = TRUE)

Multivariate REML Method

Description

Estimating the variance components under the multivariate mixed effects model using REML methods

Usage

MMeM_reml(fml, data, factor_X, T.start, E.start, maxit = 50,
  tol = 1e-09)

Arguments

fml

a two-sided linear formula object describing both the fixed-effects and random-effects parts of the model, with the response on the left of a ~ operator. For univariate response, put variable name directly; for multivariate responses combine variables using concatenate operator, for example, for bivariate responses, c(var1, var2). The predictor terms are separated by + operators, on the right. Random-effects terms are distinguished by vertical bars '|' separating expressions for design matrices from grouping factors.

data

data frame containing the variables named in formula.

factor_X

(logical) indicating whether predictor is a factor or continuous. By default is TRUE

T.start

the starting matrix for the variance covariance matrix of the block random effects, it has to be positive definite q by q symmetric matrix.

E.start

the starting matrix for the variance covariance matrix of the block random effects, it has to be positive definite q by q symmetric matrix.

maxit

the maximum number of iterations

tol

the convergence tolerance

Details

Suppose n observational units, q variates, p fixed effects coefficients and s random effects units. The model supports multivariate mixed effects model for one-way randomized block design with equal design matrices:

Y=XB+ZU+EY = XB + ZU + E

where Y is n by q response variates matrix; X is n by p design matrix for the fixed effects; B is p by q coefficients matrix for the fixed effects; Z is n by s design matrix for the random effects; U is s by q matrix for the random effects; E is n by q random errors matrix.

The model also supports simple OLS multivariate regression:

y=Xb+Zu+ey = Xb + Zu + e

where y is n by 1 response vector; b is p by 1 coefficients vector for the fixed effects; u is s by 1 matrix for the random effects.

Value

The function returns a list with the following objects:

  • T.estimates is the estimated variance covariance components of the variance covariance matrix of the block random effects

  • E.estimates is the estimated variance covariance components of the variance covariance matrix of the residuals

  • VCOV is the asymptotic dispersion matrix of the estimated variance covariance components for the block random effects and the residuals.

References

Meyer, K. "Maximum likelihood estimation of variance components for a multivariate mixed model with equal design matrices." Biometrics 1985: 153,165.

Examples

data(simdata)
T.start <- matrix(c(10,5,5,15),2,2)
E.start <- matrix(c(10,1,1,3),2,2)
results_reml <- MMeM_reml(fml = c(V1,V2) ~ X_vec + (1|Z_vec), data = simdata,
factor_X = TRUE, T.start = T.start, E.start = E.start, maxit = 10)

parses formulas to creates model matrices

Description

parses formulas to creates model matrices

Usage

MMeM_terms(fml, data, factor_X)

Arguments

fml

a two-sided linear formula object describing both the fixed-effects and random-effects parts of the model, with the response on the left of a ~ operator. For univariate response, put variable name directly; for multivariate responses combine variables using concatenate operator, for example, for bivariate responses, c(var1, var2). The predictor terms are separated by + operators, on the right. Random-effects terms are distinguished by vertical bars '|' separating expressions for design matrices from grouping factors.

data

data frame containing the variables named in formula.

factor_X

(logical) indicating whether predictor is a factor or continuous. By default is TRUE


simulated bivariate data

Description

This is a simulated data with 2 dependent variables and one fixed effects and one random effects

Usage

data(simdata)

Details

simulated datasets