Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

devfun2

Deviance Function 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 = if(isLMM(fm)) TRUE else NA,
        transfuns = list(from.chol = Cv_to_Sv,
                           to.chol = Sv_to_Cv,
                             to.sd = identity), ...)

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 list of 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, (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)))

lme4

Linear Mixed-Effects Models using 'Eigen' and S4

v1.1-26
GPL (>= 2)
Authors
Douglas Bates [aut] (<https://orcid.org/0000-0001-8316-9503>), Martin Maechler [aut] (<https://orcid.org/0000-0002-8685-9910>), Ben Bolker [aut, cre] (<https://orcid.org/0000-0002-2127-0443>), Steven Walker [aut] (<https://orcid.org/0000-0002-4394-9078>), Rune Haubo Bojesen Christensen [ctb] (<https://orcid.org/0000-0002-4494-3399>), Henrik Singmann [ctb] (<https://orcid.org/0000-0002-4842-3657>), Bin Dai [ctb], Fabian Scheipl [ctb] (<https://orcid.org/0000-0001-8172-3603>), Gabor Grothendieck [ctb], Peter Green [ctb] (<https://orcid.org/0000-0002-0238-9852>), John Fox [ctb], Alexander Bauer [ctb], Pavel N. Krivitsky [ctb, cph] (<https://orcid.org/0000-0002-9101-3362>, shared copyright on simulate.formula)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.