Deviance Function in Terms of Standard Deviations/Correlations
devfun2.RdThe 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.
Arguments
- fm
a fitted model inheriting from class
"merMod".- useSc
(
logical) indicating whether a scale parameter has been in the model or should be used.
- transfuns
a
listoffunctions for converting parameters to and from the Cholesky-factor scale- scale
a character string indicating the scale of the argument of the deviance function.
- ...
arguments passed to the internal
profnamesfunction (signames=TRUEto use old-style.sigxx names,FALSEuses (sd_cor|xx); alsoprefix=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, (i.e., not the REML criterion).
- thopt
the optimal variance-covariance parameters on the “theta” (Cholesky factor) scale
- stderr
standard errors of fixed effect parameters
Note
Even if the original model was fitted using REML=TRUE as by default
with lmer(), this returns the deviance, i.e., the objective
function for maximum (log) likelihood (ML).
For the REML objective function, use getME(fm, "devfun")
instead.
Examples
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)))
#> [1] "Mean relative difference: 0.09681211"