lme4 (version 1.1-18-1)

devfun2: Deviance function defined in terms of standard deviations/correlations

Description

The deviance is profiled with respect to the fixed-effects parameters but not with respect to sigma; that is, the function takes parameters for the variance-covariance parameters and for the residual standard deviation. The random-effects variance-covariance parameters are on the standard deviation/correlation scale, not the theta (Cholesky factor) scale.

Usage

devfun2(fm, useSc,
   transfuns = list(from.chol = Cv_to_Sv,
                    to.chol = Sv_to_Cv, to.sd = identity), ...)

Arguments

fm

a fitted model of class ‘merMod’

useSc

(logical) whether a scale parameter is used

transfuns

functions for converting parameters to and from the Cholesky-factor scale

arguments passed to the internal profnames function (signames=TRUE to use old-style .sigxx names, FALSE uses (sd_cor|xx); also prefix=c("sd","cor"))

Value

Returns a function that takes a vector of standard deviations and correlations and returns the deviance (or REML criterion). The function has additional attributes

optimum

a named vector giving the parameter values at the optimum

basedev

the deviance at the optimum (not the REML criterion, even if the original model was fitted using REML=TRUE)

thopt

the optimal variance-covariance parameters on the “theta” (Cholesky factor) scale

stderr

standard errors of fixed effect parameters

Examples

Run this code
# NOT RUN {
m1 <- lmer(Reaction~Days+(Days|Subject),sleepstudy)
dd <- devfun2(m1,useSc=TRUE)
pp <- attr(dd,"optimum")
## extract variance-covariance and residual std dev parameters
sigpars <- pp[grepl("^\\.sig",names(pp))]
all.equal(unname(dd(sigpars)),deviance(refitML(m1)))
# }

Run the code above in your browser using DataCamp Workspace