#' 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.