File: biasCorrectionGaussian.R

package info (click to toggle)
r-cran-caic4 1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 356 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,165 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
biasCorrectionGaussian <-
function(m, sigma.penalty, analytic) {
  # A function that calls the bias correction functions.
  #
  # Args: 
  #   mer    = Object of class lmerMod or lme
  #   sigma.penalty = Number of estimated variance components in the residual error covariance
  #   analytic = FALSE if the numeric hessian of the (restricted) marginal log-
  #              likelihood from the lmer optimization procedure should be used.
  #              Otherwise (default) TRUE, i.e. use a analytical version that 
  #              has to be computed.
  #
  # Returns:
  #   bc = Bias correction for a mixed model.
  #
  zeroLessModel <- deleteZeroComponents(m)
  if (inherits(zeroLessModel, "lm")) {
    return(zeroLessModel$rank)
  }
  model <- getModelComponents(zeroLessModel, analytic)
  if (identical(m, zeroLessModel)) {
    bc       <- calculateGaussianBc(model, sigma.penalty, analytic)
    newModel <- NULL
    new      <- FALSE
  } else {
    bc       <- calculateGaussianBc(model, sigma.penalty, analytic)
    newModel <- zeroLessModel
    new      <- TRUE
  }
  return(list(bc = bc, newModel = newModel, new = new))
}