View source: R/GroupProfiles.R
| GroupProfiles | R Documentation |
This function calculates the mean of specified covariates for each trajectory group. It first assigns each individual to a group based on the highest posterior probability, then computes the average value of each provided covariate for all members of that group.
GroupProfiles(sol, Y, A, X)
sol |
A trajectory object returned by the |
Y |
The response variable matrix, as used in the 'trajeR' call. |
A |
The time variable matrix, as used in the 'trajeR' call. |
X |
A numeric matrix or data frame of covariates for which the profiles are to be calculated. Each column represents a different covariate. |
A matrix where rows correspond to the covariates in 'X' and columns correspond to the trajectory groups. Each cell contains the mean of a covariate for a specific group.
data <- read.csv(system.file("extdata", "CNORM2gr.csv", package = "trajeR"))
data <- as.matrix(data)
sol <- trajeR(
Y = data[, 2:6], A = data[, 7:11], Risk = data[, 12, drop = FALSE],
degre = c(2, 2), Model = "CNORM", Method = "L"
)
GroupProfiles(sol, Y = data[, 2:6], A = data[, 7:11], X = data[, 12, drop = FALSE])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.