GroupProfiles: Generate Group Profiles Based on Covariates

View source: R/GroupProfiles.R

GroupProfilesR Documentation

Generate Group Profiles Based on Covariates

Description

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.

Usage

GroupProfiles(sol, Y, A, X)

Arguments

sol

A trajectory object returned by the trajeR function.

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.

Value

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.

Examples

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])

trajeR documentation built on Aug. 4, 2026, 1:09 a.m.