R/lmer.R

Defines functions lmerNoFit

Documented in lmerNoFit

##' The \code{lmerNoFit} function can be used to get trivial starting values.
##' This is mainly used to verify the algorithms to reproduce the fit by
##' \code{\link[lme4]{lmer}} when starting from trivial initial values.
##'
##' @rdname rlmer
##' @param initTheta parameter to initialize theta with (optional)
##' @examples
##' \dontrun{
##'   ## start from lmer's initial estimate, not its fit
##'   rlmer(Yield ~ (1|Batch), Dyestuff, init = lmerNoFit)
##' }
##' @importFrom lme4 mkMerMod
##' @export
lmerNoFit <- function(formula, data = NULL, ..., initTheta) {
    mc <- match.call()
    mc[[1]] <- quote(lmer)
    ## trick it...
    fm <- lmer(formula, data, ...)
    devfun <- lmer(formula, data, ..., devFunOnly=TRUE)
    if (!missing(initTheta)) devfun(initTheta)
    fakeOpt <- list(fval=devfun(environment(devfun)$pp$theta),
                    conv=1,
                    par=environment(devfun)$pp$theta,
                    ierr=0)
    reTrms <- list(flist=fm@flist,
                   cnms=fm@cnms,
                   Gp=fm@Gp,
                   lower=fm@lower)
    fr <- fm@frame
    mkMerMod(environment(devfun), fakeOpt, reTrms, fr, mc)
}

Try the robustlmm package in your browser

Any scripts or data that you put into this service are public.

robustlmm documentation built on July 30, 2026, 5:11 p.m.