R/dist_custom.R

Defines functions toString.bmerCustomDist

setClass("bmerCustomDist",
         representation(fnName = "name",
                        fn     = "function",
                        chol   = "logical",
                        scale  = "character"),
         contains = "bmerDist",
         validity = function(object) object@scale == "log" || object@scale == "dev" || object@scale == "none")

toString.bmerCustomDist <- function(x, digits = getOption("digits"), ...) {
  paste("custom(fn = ", x@fnName,
        ", chol = ", x@chol,
        ", scale = ", x@scale,
        ", common.scale = ", x@commonScale,
        ")", sep = "")
}

setMethod("getExponentialTerm", "bmerCustomDist",
  function(object, Lambda.t) {
    result <- object@fn(if (object@chol) Lambda.t else crossprod(Lambda.t))
    if (object@scale == "log") {
      result <- -2 * result
    } else if (object@scale == "none") {
      result <- -2 * log(result)
    }
    c(0, result)
  })

Try the blme package in your browser

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

blme documentation built on May 30, 2017, 1:22 a.m.