R/modelStratify.R

Defines functions .lcModelStratify

#' @include modelApprox.R
setClass('lcModelStratify', contains = 'lcModelPartition')

.lcModelStratify = function(...) new('lcModelStratify', ...)

#. converged ####
#' @rdname interface-custom
setMethod('converged', 'lcModelStratify', function(object, ...) {
  TRUE
})


#. predictPostprob ####
#' @rdname interface-custom
#' @inheritParams predictPostprob
setMethod('predictPostprob', 'lcModelStratify', function(object, newdata = NULL, ...) {
  if (is.null(newdata)) {
    return(postprob(object))
  }

  assignments = .stratifyTrajectories(
    method[['stratify', eval = FALSE]],
    data = newdata,
    id = idVariable(method)
  ) %>%
    as.integer()

  pp = postprobFromAssignments(assignments, nClusters(object))
  colnames(pp) = clusterNames(object)
  return(pp)
})

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.