Function for performing MHPCA decomposition described in "Multilevel Hybrid Principal Components Analysis For Region-Referenced Functional EEG Data" by Campos et al. (202?), including estimation of fixed effects and marginal covariance functions, marginal eigencompoents, subject-specific scores, variance components, and measurement error variance.

MHPCA_decomp(
  data,
  fve_cutoff,
  nknots,
  maxiter = 1000,
  epsilon = 0.001,
  reduce = TRUE,
  quiet = FALSE
)

Arguments

data

dataframe in long format with six labeled columns (Repetition: (character vector), Subject: subject IDs (character vector), Group: subject group (character vector), func: functional argument (numeric vector), reg: regional argument (character vector), y: region-referenced functional data (numeric vector)) and row length equal to the length of the vectorized region-referenced Repetitions across all subjects and groups

fve_cutoff

fraction of variance cutoff for reducing the number of product components used in the mixed effects model (scalar in (0, 1))

nknots

number of knots to use for smoothing splines

maxiter

maximum number of iterations for MM algorithm (scalar)

epsilon

epsilon value for determining log-likelihood convergence (scalar)

reduce

should the number of product components be reduced and the mixed effects model re-estimated (logical)

quiet

display messages for timing (logical)

Value

A list with

  • mu: the overall mean function (vector),

  • eta: group-region-level-specific shifts (dataframe),

  • covar: list with total, between and within covariance matrices,

  • marg: list with between and within marginal covariances,

  • model: list of models for each group, including scores and variances,

  • data: data with all of the different pieces from the estimation,

  • FVE: fraction of variance explained.