Skip to contents

Computes the temporal smoothness penalty for factor scores using second-order differences. This penalty measures how "wiggly" the factor activation profiles are, with higher values indicating more high-frequency noise.

Usage

compute_smoothness_penalty(factor_scores)

Arguments

factor_scores

A list of N matrices, each (T_i x r), containing factor scores for each subject.

Value

A numeric scalar representing the total smoothness penalty across all subjects and factors.

Details

The smoothness penalty is computed as: $$ \text{smoothness} = \sum_{i=1}^{N} \sum_{j=1}^{r} \sum_{t=3}^{T_i} (z_{i,j,t} - 2z_{i,j,t-1} + z_{i,j,t-2})^2 $$ where \(z_{i,j,t}\) is the j-th factor score for subject i at time t.

This is equivalent to summing the squared second-order differences across all time series. When r is too large, models tend to fit high-frequency noise, producing wiggly factors with high smoothness penalties.

Examples

if (FALSE) { # \dontrun{
# Compute factor scores first
mfa_fit <- compute_factor_scores_mfa(mfa_fit, list_of_data)
# Then compute smoothness
smooth_val <- compute_smoothness_penalty(mfa_fit$factor_scores)
} # }