R/re.plot.R

Defines functions re.plot

Documented in re.plot

#' A LCGA Model PLotting Function
#'
#' This function helps you plot predicted latent classes generated by a newly-specified lcmm model. This function is meant to work in tandem with the other package functions in which columns names for new data sets are specified by the package functions.
#' @param df_stacked enter data set with multiple rows for each ID.
#' @param link enter link function to use in lcmm model specification.
#' @param ng enter number of latent classes you would like to search for. 
#' @param smooth would you like the plot to smooth (using loess) the time-varying outcome for each latent class?
#' @keywords lcmm
#' @export
#' @examples
#' re.plot()

re.plot <- function(df_stacked, link, ng, smooth='none') {
  # model
  model <- build.lcmm(df_stacked, "months", "outcomes", "id", link=link, ng=ng)
  # classes
  classes <- model$pprob$class
  # assign classes to df
  df_complete <- id.class.parser(df_stacked, "id", classes)
  # plot
  p <- class.plot(model, df_complete, smooth=smooth)
  # end
  return(p)
}
noahlorinczcomi/sgmm documentation built on Aug. 23, 2023, 1:28 a.m.