Skip to contents

This function applies PCA to the concatenated data across all subjects, then for each subject i, computes the mean of the top r_dim principal component scores as a single feature vector. This is useful for initializing cluster assignments in mixture models.

Usage

extract_subject_features_by_singlePCA(list_of_data, r_dim = 2)

Arguments

list_of_data

A list of (T_i x M) matrices, where each element represents time-series data for one subject. T_i is the number of time points for subject i, and M is the number of variables (e.g., muscles in EMG data).

r_dim

Number of principal components to extract. Defaults to 2.

Value

A numeric matrix of shape (N x r_dim), where N=length(list_of_data). Each row contains the mean PC scores for one subject.

Details

The function first concatenates all subject data into a single matrix, performs PCA on this combined dataset, and then computes the mean of the PC scores for each subject's time points. This provides a low-dimensional representation of each subject that can be used for clustering initialization.

Examples

if (FALSE) { # \dontrun{
# Create example data
N <- 10
M <- 8
list_of_data <- lapply(1:N, function(i) matrix(rnorm(100 * M), 100, M))

# Extract 2D features for each subject
features <- extract_subject_features_by_singlePCA(list_of_data, r_dim = 2)
dim(features)  # Should be 10 x 2
} # }