Processes data by fitting a mean GAM model, extracting residuals, performing FPCA, and merging the results to create an enhanced dataset for functional regression analysis.
Arguments
- input_data
Raw pupil data
- k_mean
Number of basis functions for mean model smooth terms (default: 30)
- k_fpca
Number of knots for FPCA estimation (default: 15)
- example
Choice for different model. If
example = "original", will only include use as the only covariate. Ifexample = "original", will include use, age and gender as covariates.
Value
A tibble containing:
Original pupil variables
FPCA eigenfunctions (Phi1, Phi2,...)
Sorted by ID and domain
Examples
if (requireNamespace("mgcv", quietly = TRUE)) {
data(pupil)
processed_data <- prepare_pupil_fpca(pupil)
processed_data <- prepare_pupil_fpca(pupil, k_mean = 5, k_fpca = 5)
}