ranefUvcov {lme4GS}R Documentation

Extract the conditional means of the random effects

Description

A function to extract the conditional means of the random effects from a fitted model object.

Usage

  ranefUvcov(object, postVar = FALSE, drop = FALSE, whichel = names(ans), ...)

Arguments

object

is an object returned by lmerUvcov.

postVar

a logical argument indicating if the conditional variance-covariance matrices of the random effects should be added as an attribute.

drop

should components of the return value that would be data frames with a single column, usually a column called “(Intercept)”, be returned as named vectors instead?.

whichel

character vector of names of grouping factors for which the random effects should be returned.

...

some methods for these generic functions require additional arguments.

Details

The function ranef extract the conditional means for the liner mixed effects model:

y=Xβ + Z1* u1*+...+Zq* uq*+e,

where Zj*=Zj Lj, with Lj from Cholesky factorization for Kj. Alternatively, Zj*=ZjΓjΛ1/2, with Γj and Λj the matrix of eigen-vectors and eigen-values obtained from the eigen-value decomposition for Kj. So, the conditional means of the random effects in the linear mixed effects model:

y=Xβ + Z1 u1 + ... + Zq uq + e,

are obtained as follows: ûj=Ljûj* if the Cholesky factorization is used or ûjjΛj1/2ûj* if the the eigen-value decomposition is used.

Value

A list of data frames, one for each grouping factor.

Author(s)

Paulino Perez-Rodriguez

References

Caamal-Pat D., P. Perez-Rodriguez, J. Crossa, C. Velasco-Cruz, S. Perez-Elizalde, M. Vazquez-Pena. 2021. lme4GS: An R-Package for Genomic Selection. Front. Genet. 12:680569. doi: 10.3389/fgene.2021.680569 doi: 10.3389/fgene.2021.680569

Examples




library(BGLR)
library(lme4GS)

########################################################################
#Example wheat
########################################################################
data(wheat)
X<-wheat.X
Z<-scale(X,center=TRUE,scale=TRUE)
G<-tcrossprod(Z)/ncol(Z)
A<-wheat.A
rownames(G)<-colnames(G)<-rownames(A)
y<-wheat.Y[,1]

data<-data.frame(y=y,m_id=rownames(G),a_id=rownames(A))

fm1<-lmerUvcov(y~(1|m_id)+(1|a_id),data=data,
               Uvcov=list(m_id=list(K=G),a_id=list(K=A)))

summary(fm1)

#Predictions
plot(y,predict(fm1))

#Random effects
ranef(fm1)

#Equivalently
ranefUvcov(fm1)




[Package lme4GS version 0.1 Index]