tests/testthat/setup-method-functions.R

# KML ####
lcMethodTestKML = function(...) {
  lcMethodKML(response = 'Value', nbRedrawing = 1, maxIt = 10, ..., seed = 1)
}

# lcmm ####
lcMethodTestLcmmGMM = function(..., init = NULL, seed = 1) {
  mc = match.call.all()
  mc$fixed = Value ~ 1
  mc$maxiter = 10

  do.call(lcMethodLcmmGMM, as.list(mc)[-1])
}

lcMethodTestLcmmGBTM = function(..., init = NULL, seed = 1) {
  mc = match.call.all()
  mc$fixed = Value ~ 1
  mc$maxiter = 10

  do.call(lcMethodLcmmGBTM, as.list(mc)[-1])
}

# lme4 ####
lcMethodTestGCKM = function(...) {
  lcMethodGCKM(formula = Value ~ (1 | Traj), ...)
}


# Custom ####
lcMethodTestRandom = function(...) {
  lcMethodRandom(response = 'Value', ...)
}

lcMethodTestStratify = function(...) {
  lcMethodStratify(response = 'Value', ...)
}

lcMethodTestLMKM = function(...) {
  lcMethodLMKM(formula = Value ~ Assessment, ..., seed = 1)
}


lcMethodTestTwoStep = function(...) {
  lcMethodFeature(response = 'Value', ...)
}


# Error ####
# method class that triggers an error during fitting
setClass('lcMethodError', contains = 'lcMethod')

lcMethodError = function(
  response = 'Value',
  time = getOption('latrend.time'),
  id = getOption('latrend.id'),
  nClusters = 2,
  ...
) {
  mc = match.call.all()
  mc$Class = 'lcMethodError'
  do.call(new, as.list(mc))
}

Try the latrend package in your browser

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

latrend documentation built on March 31, 2023, 5:45 p.m.