fitLMM: Fit a linear mixed model

View source: R/lmm.R

fitLMMR Documentation

Fit a linear mixed model

Description

Fit a linear mixed model of the form y = Xb + e where e follows a multivariate normal distribution with mean 0 and variance matrix sigmasq_g K + sigmasq_e I, where K is a known kniship matrix and I is the identity matrix.

Usage

fitLMM(Kva, y, X, reml = TRUE, check_boundary = TRUE, tol = 0.0001,
  use_cpp = TRUE, compute_se = FALSE)

Arguments

Kva

Eigenvalues of K (calculated by eigen_rotation())

y

Rotated phenotypes (calculated by eigen_rotation())

X

Rotated covariate matrix (calculated by eigen_rotation())

reml

If TRUE, use REML; otherwise use ordinary maximum likelihood.

check_boundary

If TRUE, explicitly check log likelihood at 0 and 1.

tol

Tolerance for convergence

use_cpp

= if TRUE, use c++ version of code

compute_se

= if TRUE, return the standard error of the hsq estimate using the Fisher Information matrix of the MLE estimate. The standard error will be in an attr of hsq in the output. Currently requires use_cpp = FALSE, and so if compute_se=TRUE we take use_cpp=FALSE.

Value

List containing estimates of beta, sigmasq, hsq, sigmasq_g, and sigmasq_e, as well as the log likelihood (loglik). If compute_se=TRUE, the output also contains hsq_se.

Examples

data(recla)
e <- eigen_rotation(recla$kinship, recla$pheno[,1], recla$covar)
result <- fitLMM(e$Kva, e$y, e$X)

# also compute SE
wSE <- fitLMM(e$Kva, e$y, e$X, compute_se = TRUE, use_cpp=FALSE)
c(hsq=wSE$hsq, SE=wSE$hsq_se)


kbroman/lmmlite documentation built on May 10, 2023, 6:05 p.m.