In this vignette we show how to use the
package to apply the methods proposed in Colosimo and Pacella et
al. (2010) to build control charts for monitoring a multivariate
functional quality characteristic. Let us show how the
funcharts package works through an example with the dataset
First of all, starting from the discrete data, let us build the
multivariate functional data objects of class
library(funcharts) data("air") <- get_mfd_list(air, grid = 1:24) mfdobj <- dim(mfdobj$coefs) nobs nobs#>  355 plot_mfd(mfdobj)
In order to perform the statistical process monitoring analysis, we divide the data set into a phase I and a phase II dataset.
<- 1:300 rows1 <- 301:355 rows2 <- mfdobj[rows1] mfdobj1 <- mfdobj[rows2]mfdobj2
mfd we provide a function
pca_mfd, which is a wrapper to
returns multivariate functional principal component scores summed over
fda::pca.fd returns an array of scores when
providing a multivariate functional data object). Moreover, the
eigenfunctions or multivariate functional principal components given in
harmonics argument are converted to the
class. We also provide a plot function for the eigenfunctions (the
harm selects which components to plot).
<- pca_mfd(mfdobj1) pca plot_pca_mfd(pca, harm = 1:3)
control_charts_pca provides a data frame
with all the information required to plot the desired control charts on
multivariate functional data, based on the Hotelling’s \(T^2\) and the squared prediction error
statistics (see Colosimo and Pacella (2010), Capezza et al. (2020)).
Among the arguments, you can pass a
tuning_data set, that
is not used for model estimation/training, but only to estimate control
chart limits. If this data set is not provided, control chart limits are
calculated on the basis of the training data. The argument
newdata contains the phase II data set of observations of
multivariate functional covariates to be monitored. The function
plot_control_charts returns the plot of the control
<- control_charts_pca(pca = pca, newdata = mfdobj2) cclist_pca plot_control_charts(cclist_pca)
Once an out-of-control observation is identified in a control chart, one can obtain the contribution of the functional covariates to the monitoring statistics to understand which variable was possibly responsible of the anomalous observation.
We can get the out of control observations using
<- which_ooc(cclist_pca) ooc_index ooc_index#> $T2 #> n id #> 1 2 302 #> 2 5 305 #> 3 9 309 #> 4 12 312 #> 5 23 323 #> 6 32 332 #> #> $spe #> n id #> 1 9 309 #> 2 25 325 #> 3 28 328 #> 4 34 334 #> 5 48 348 #> 6 52 352 #> 7 54 354 #> 8 55 355
From the control charts it is possible to see some phase II
observations out of control. For example, let us consider observation 9.
We can exploit the contribution plots using the function
cont_plot to identify the variables responsible of the
anomaly. The contributions are plotted as bar plots, against upper
control limits estimated empirically on the training data.
Finally, we can also plot any multivariate functional observation
against a reference data set by using the function
plot_mon(cclist_pca, fd_train = mfdobj1, fd_test = mfdobj2)
This helps to understand which profiles were anomalous. Variables exceeding contribution plot limits are coloured in red.