# NOT RUN {
data(latrendData)
# Stratification based on the mean response level
clusfun <- function(data, response, id, time, ...) {
clusters <- data.table::as.data.table(data)[, mean(Y) > 0, by = Id]$V1
lcModelCustom(data = data,
trajectoryAssignments = factor(clusters, levels = c(FALSE, TRUE), labels = c("Low", "High")),
response = response,
time = time,
id = id)
}
method <- lcMethodCustom(response = "Y", fun = clusfun, id = "Id", time = "Time")
model <- latrend(method, data = latrendData)
# }
Run the code above in your browser using DataLab