R/clv_template_controlflow_pmf.R

Defines functions clv.template.controlflow.pmf

clv.template.controlflow.pmf <- function(clv.fitted, x){

  clv.controlflow.check.prediction.params(clv.fitted)
  x <- sort(unique(x))

  l.res.pmf <- lapply(x, function(i){
    dt.pmf <- clv.model.pmf(clv.model = clv.fitted@clv.model, clv.fitted = clv.fitted, x = i)
    # measure.vars = NULL: all except id vars
    return(melt(dt.pmf, id.vars="Id", measure.vars=NULL, variable.name="pmf", na.rm=FALSE))
  })

  return(dcast(rbindlist(l.res.pmf), Id~pmf))
}
bachmannpatrick/CLVTools documentation built on Oct. 29, 2023, 2:16 p.m.