Compute Smoothness Penalty for Factor Scores
Source:R/r_selection_advanced.R
compute_smoothness_penalty.RdComputes 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.
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)
} # }