lme4ord for methodologists

Create new (co)variance classes by defining a method for the setReTrm generic

 setReTrm.myClass <- function(object, addArgsList, devfunEnv = NULL) {
    ## Transposed model matrix (as an object of class repSparse)
    Zt <- resetTransConst(kr(t(as.repSparse(object$modMat)),
                               as.repSparse(object$grpFac)))
    
    ## Relative covariance factor (as an object of class repSparse)
    nc <-    ncol(object$modMat)
    nl <- nlevels(object$grpFac)
    templateBlock <- repSparseTri(   diagVals = rep(1,        nc    ),
                                  offDiagVals = rep(0, choose(nc, 2)),
                                  low = FALSE)
    Lambdat <- rep(templateBlock, nl, type = "diag")

    ## Package up the results
    packReTrm(object, Zt, Lambdat)
}

That's it! Now this new covariance structure may be used in formulas passed to strucGlmer:

strucGlmer(y ~ x + myClass(x | g), ...)

source »