EMMREML: Fitting Mixed Models with Known Covariance Structures

Overview

The EMMREML package provides efficient algorithms for fitting mixed models with known covariance structures. It is particularly useful for genomic prediction, quantitative genetics, and other applications where the genetic relationships between individuals or items are known.

Key Features

Installation

# Install from CRAN
install.packages("EMMREML")

# Or the development version from GitHub:
# install.packages("devtools")
# devtools::install_github("dakdemir/EMMREML")

Basic Usage

Single Kernel Model

library(EMMREML)

# Example data
n <- 200
M1 <- matrix(rnorm(n*300), nrow=n)
K1 <- cov(t(M1))
K1 <- K1/mean(diag(K1))  # Normalize

# Generate phenotype data
covY <- 2*K1 + 1*diag(n)  # Genetic + residual covariance
Y <- 10 + crossprod(chol(covY), rnorm(n))  # Phenotype with mean 10

# Create data frame
df <- data.frame(y = Y, x = rnorm(n), id = 1:n)

# Fit model using formula interface
mod <- emmreml(
  formula = y ~ x,
  data = df,
  K = K1,
  getVarBeta = TRUE,
  verbose = TRUE
)

# View results
print(mod)
summary(mod)

# Predictions
pred <- predict(mod)

Multi-Kernel Model

# Fit model with multiple kernels/random effects
mod_multi <- emmremlMultiKernel(
  formula = y ~ x,
  random = list(id = ~ id, group = ~ group - 1),
  data = df_multi,
  K = list(K1, K2),
  getPEV = TRUE
)

Multivariate Model

# Fit multivariate model for multiple traits
mod_mv <- emmremlMultivariate(
  formula = cbind(y1, y2, y3) ~ x,
  random = ~ id,
  data = df_mv,
  K = K1,
  getVarB = TRUE
)

References

For more details on the underlying algorithms:

Version 5.1 Update

The 5.1 release includes:

See the TODO.md file for upcoming improvements.

Citation

If you use EMMREML in your research, please cite:

Akdemir D, Godfrey OU (2025). EMMREML: Fitting Mixed Models with Known Covariance Structures. R package version 5.1, https://github.com/dakdemir/EMMREML.