FMRCC_PhaseI: Phase I of the FMRCC

View source: R/fmrcc.R

FMRCC_PhaseIR Documentation

Phase I of the FMRCC

Description

Performs Phase I of the Functional Mixture Regression Control Chart methodology, which consists of model estimation and control limit calculation using training and tuning datasets.

Usage

FMRCC_PhaseI(
  Y_train,
  X_train,
  Y_tun,
  X_tun,
  FVEy,
  FVEx,
  studentized = T,
  alpha = 0.01,
  intercept = T,
  init_met = "kmeans",
  ninit = 10,
  groups = 1:5,
  sigma_par = c("VVV", "EEE", "VII", "EII"),
  scale = T,
  ncompx = NULL,
  ncompy = NULL,
  userBwCov = NULL
)

Arguments

Y_train

Training response variable. Object of class 'mfd' (dense functional data) or 'list' (sparse functional data). For dense data, pca_mfd is performed. For sparse data, PACE (Yao et al., 2005) via FPCA is used.

X_train

Training predictor variables. Object of class 'mfd' (dense functional), 'matrix' (scalar), or 'list' (sparse functional). For dense data, pca_mfd is performed. For sparse data, PACE (Yao et al., 2005) via FPCA is used.

Y_tun

Tuning response variable for control limit calculation. Must be same type as Y_train.

X_tun

Tuning predictor variables for control limit calculation. Must be same type as X_train.

FVEy

Fraction of variance explained threshold for response variable.

FVEx

Fraction of variance explained threshold for covariates. Ignored if covariates are scalar.

studentized

Logical. If TRUE, statistics are studentized. Default is TRUE.

alpha

Type I error rate for control limit calculation. Default is 0.01.

intercept

Logical. If TRUE, model includes an intercept. Default is TRUE.

init_met

Initialization method: 'kmeans' or 'random'. If 'random', ninit initializations are performed and the model with lowest BIC is retained. Default is 'kmeans'.

ninit

Number of random starts for model estimation. Ignored if init_met = 'kmeans'. Default is 10.

groups

Integer vector specifying number of mixture components to consider. Default is 1:5.

sigma_par

Character vector of covariance parametrizations to consider. Options are 'VVV' (variable volume, shape, orientation), 'EEE' (equal volume, shape, orientation), 'VII' (variable volume, spherical), 'EII' (equal volume, spherical). Default is c('VVV','EEE','VII','EII').

scale

Logical. Should dense functional objects be scaled? Default is TRUE.

ncompx

Integer. Number of principal components to retain for functional covariates. If NULL, chosen according to FVEx. Default is NULL.

ncompy

Integer. Number of principal components to retain for functional response. If NULL, chosen according to FVEy. Default is NULL.

userBwCov

Bandwidth for covariance smoothing in PACE. See FPCA for details. Default is NULL.

Value

A list containing:

model

The best fitted mixture regression model

phaseI

Phase I results including control limits

estimate

Estimation results including values to studentize residuals

fpca

FPCA results for response and (if applicable) covariates

BIC_plt

ggplot object showing BIC values across models

studentized

Logical indicating if studentization was used

intercept

Logical indicating if intercept was included

type_y

Character indicating response type ('dense' or 'sparse')

type_x

Character indicating covariate type ('dense', 'sparse', or 'scalar')

References

Capezza, C., Centofanti, F., Forcina, D., Lepore, A., & Palumbo, B. (2025). Functional Mixture Regression Control Chart. Accepted for publication in Annals of Applied Statistics. arXiv:2410.20138.

Yao, F., Müller, H. G., & Wang, J. L. (2005). Functional data analysis for sparse longitudinal data. Journal of the American Statistical Association, 100(470), 577-590.

See Also

FMRCC_PhaseII, FPCA

Examples


# Example with dense functional data
# Length of the functional grid
l <- 100
# Number of observations
n <- 300

# Generate training in-control data with three equally-sized clusters, maximum dissimilarity
data <- simulate_data_fmrcc(n_obs = n, delta_1 = 1, delta_2 = 0.5, len_grid = l, severity = 0)
X_train_mfd <- get_mfd_list(data_list = data['X'], n_basis = 20)
Y_train_mfd <- get_mfd_list(data_list = data['Y'], n_basis = 20)

# Generate tuning in-control data with three equally-sized clusters, maximum dissimilarity
data <- simulate_data_fmrcc(n_obs = n, delta_1 = 1, delta_2 = 0.5, len_grid = l, severity = 0)
X_tun_mfd <- get_mfd_list(data_list = data['X'], n_basis = 20)
Y_tun_mfd <- get_mfd_list(data_list = data['Y'], n_basis = 20)

# Example with dense functional data
phaseI_results <- FMRCC_PhaseI(
  Y_train = Y_train_mfd,
  X_train = X_train_mfd,
  Y_tun = Y_tun_mfd,
  X_tun = X_tun_mfd,
  FVEy = 0.95,
  FVEx = 0.90,
  alpha = 0.01,
  groups = 1:3,
  sigma_par = c('VVV', 'EEE')
)

# View BIC plot
phaseI_results$BIC_plt


funcharts documentation built on Dec. 12, 2025, 5:06 p.m.