Type: | Package |
Title: | Partially Observed Integrated Functional Depth |
Version: | 2.0.0 |
Maintainer: | Antonio Elías <antonioefz91@gmail.com> |
Description: | Integrated Functional Depth for Partially Observed Functional Data and applications to visualization, outlier detection and classification. It implements the methods proposed in: Elías, A., Jiménez, R., Paganoni, A. M. and Sangalli, L. M., (2023), "Integrated Depth for Partially Observed Functional Data", Journal of Computational and Graphical Statistics, <doi:10.1080/10618600.2022.2070171>. Elías, A., Jiménez, R., & Shang, H. L. (2023), "Depth-based reconstruction method for incomplete functional data", Computational Statistics, <doi:10.1007/s00180-022-01282-9>. Elías, A., Nagy, S. (2024), "Statistical properties of partially observed integrated functional depths", TEST, <doi:10.1007/s11749-024-00954-6>. |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
Depends: | R (≥ 3.5.0) |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
Imports: | stats, ggplot2, tibble, magrittr, reshape2, patchwork, igraph |
URL: | https://github.com/aefdz/fdaPOIFD |
BugReports: | https://github.com/aefdz/fdaPOIFD/issues |
NeedsCompilation: | no |
Packaged: | 2025-06-25 07:13:29 UTC; UX325 |
Author: | Antonio Elías [aut, cre], Raúl Jiménez [ctb], Anna M. Paganoni [ctb], Laura M. Sangalli [ctb], Stanislav Nagy [ctb], Maximiliam Ofner [ctb] |
Repository: | CRAN |
Date/Publication: | 2025-06-25 12:00:17 UTC |
Integrated Depth for Partially Observed Functional Data
Description
Compute the depth measure of a partially observed functional data set proposed in [1]. If the functions are not observed in a common partially observed domain, the code first estimates the observation domain using the proposal in [2].
Usage
POIFD(data, type = c("HD", "FMD", "MBD", "MHRD"), phi, t = NULL)
Arguments
data |
If functions are observed in a partially observed common grid 'data' is a matrix 'p' by 'n', being 'n' the number of functions and 'p' the number of grid points.
The row names of the matrix should be the common evaluation grid and the column names the identifiers of each functional data.
If functions do not have a common grid, 'data'must be a list of length 'n' where each element contains the values and evaluation points of each function.
I.e. each list element must contain two vectors 'x', including the evaluation points, and 'y', the evaluated function values.
For functions without a common grid, the function |
type |
chosen depth measure. Halfspace depth ( |
phi |
phi function of weights for the POIFD. The default value is as in [1]: the proportion of observed functions at each time point. |
t |
If functions do not have a common grid, 't' represents the final common grid of evaluation points to apply the procedure to estimate the observation domain proposed in [2]. |
Details
[1] Elías, A., Jiménez, R., Paganoni, A. M., & Sangalli, L. M. (2023). Integrated depths for partially observed functional data. Journal of Computational and Graphical Statistics, 32(2), 341-352.
[2] Elías, A., Nagy, S. (2025). Statistical Properties of Partially Observed Integrated Funcional Depths. TEST, 34, 125-150.
Value
Ordered vector of depths. The names are the functions names (if provided) or the column position.
Examples
data <- exampleData$PoFDintervals
poifd <- POIFD(data, type = c("FMD"))
data <- exampleData$PoFDintervals_list
poifd <- POIFD(data, type = c("FMD"), t = seq(0, 1, length.out = 100))
Functional Boxplot for Partially Observed Functional Data
Description
Plots the Functional Boxplot for PoFD and returns the magnitude and domain outliers.
Magnitude outliers in blue, a dotted red indicates that the outlier situation occurs
in a region with less than fdom
proportion of the central region.
Usage
boxplotPOFD(data, centralRegion = 0.5, fmag = 1.5, fdom = 0)
Arguments
data |
matrix p by n, being n the number of functions and p the number of grid points. |
centralRegion |
number between 0 and 1 determining the proportion of the deepest functions that builds the central region. |
fmag |
factor to enhance the functional central region and determine the functional whiskers. Default is equal to 1.5. The whiskers provide the rule to unmask magnitude outliers. |
fdom |
factor that provides the maximum proportion of observed functions in the central region to consider a magnitude outlier as a domain outlier also. A value equals to 0 means that domain outliers are those functions that are observed on the domain where any of the functions building the central region are observed. A value equals to 1 determine as domain outlier any magnitude outlier out of the region where the central region is completely observed. |
Value
a list with the functional boxplot for PoDF the magnitude outliers and the domain outliers.
References
Sun, Y. and Genton, M. G. (2011). Functional boxplots. Journal of Computational & Graphical Statistics, 20(2):316–334.
Examples
boxplotPOFD(exampleData$PoFDextremes_outliers, centralRegion = 0.5, fmag = 1.5, fdom = 0)
Common Domain Observability
Description
Generates samples of functions observed in a common domain in the center part of the domain. See Elías et al (2020).
Usage
commondomainPOFD(data, observability = NULL, pIncomplete = NULL)
Arguments
data |
functional data completely observed. pxn matrix being n the number of curves and p the number og evaluation points. |
observability |
mean observed proportion of the domain where each function is observed. |
pIncomplete |
number between 0 and 1 related to the proportion of curves that suffers partially observability. The default is 1 meaning that all the sample curves are partially observed. |
Value
a list containing two elements 1) a functional sample and 2) the same sample of functions but partially observed following one of the schemes described in the argument type.
References
Elías, Antonio, Jiménez, Raúl, Paganoni, Anna M. and Sangalli, Laura M. (2020). Integrated Depths for Partially Observed Functional Data.
Examples
data <- sapply(1:100, function(x) runif(1)*sin(seq(0, 2*pi, length.out = 200)) +
runif(1)*cos(seq(0, 2*pi, length.out = 200)))
data_pofd <- commondomainPOFD(data, observability = 0.5, pIncomplete = 1)
Depth-based reconstruction of partially observed functional data
Description
This function implements the reconstruction procedure [1] which is based on the depth measure [2] for partially observed functional data. Missing trajectories are imputed by the mean of the k nearest neighbors within the envelope. The parameter k is tuned minimizing the Mean Squared Error of the reconstruction in the observed part of the curve.
Usage
depthbasedreconstructionPOFD(data, id_recons = 1:dim(data)[2])
Arguments
data |
Data matrix 'p' by 'n', being 'n' the number of functions and 'p' the number of grid points. The row names of the matrix should be the common evaluation grid and the column names the identifiers of each functional data. |
id_recons |
Vector indicating functions to be reconstructed. By default, all functions are reconstructed. |
Details
[1] Elías, A., Jiménez, R., & Shang, H. L. (2023). Depth-based reconstruction method for incomplete functional data. Computational Statistics, 38(3), 1507-1535.
[2] Elías, A., Jiménez, R., Paganoni, A. M., & Sangalli, L. M. (2023). Integrated depths for partially observed functional data. Journal of Computational and Graphical Statistics, 32(2), 341-352.
Value
The reconstructed data matrix 'recons_data'.
Examples
data <- exampleData$PoFDintervals
recons_data <- depthbasedreconstructionPOFD(data, id_recons = 1:2)
Envelope algorithm
Description
Code for obtaining the envelope Ji of a curve specified by the index i. The implementation is based on Algorithm 1 in [1]. References:
Usage
envelope(data, i, max_iter = 10)
Arguments
data |
Data matrix. |
i |
Index of curve. |
max_iter |
Maximum number of nearest curves considered in for loop. By default, max_iter = 5. |
Details
[1] Elías, A., Jiménez, R., & Shang, H. L. (2023). Depth-based reconstruction method for incomplete functional data. Computational Statistics, 38(3), 1507-1535.
Value
Envelope (set of indices).
exampleData
Description
An illustrative Functional Gaussian processes with different partially observed patterns with outliers and without outliers.
Usage
exampleData
Format
A list with three data sets (functions by columns):
- PoFDintervals
Partially observed functional data in intervals
- PoFDextremes
Partially Observed functional data with missing intervals at the extremes
- PoFDextremes_outliers
Same as above but including two magnitude and shape outliers
- PoFDintervals_list
Partially observed data without a common domain. Each function is one element of the list, containing the evaluation points (x) and the evaluated function (y).
References
Elías, Antonio, Jiménez, Raúl, Paganoni, Anna M. and Sangalli, Laura M. (2020). Integrated Depths for Partially Observed Functional Data.
Examples
data(exampleData)
plotPOFD(exampleData$PoFDintervals)
Random Interval Observability
Description
Generates samples of functions observed in different intervals. See Elías et al (2020).
Usage
intervalPOFD(data, observability = NULL, ninterval = NULL, pIncomplete = NULL)
Arguments
data |
functional data completely observed. pxn matrix being n the number of curves and p the number og evaluation points. |
observability |
mean observed proportion of the domain where each function is observed. |
ninterval |
if type = "interval", n_interval is an integer with the number of observed intervals 1, 2, 3... Large values of this parameter requires a large parameter p to guarantee the observability level. |
pIncomplete |
number between 0 and 1 related to the proportion of curves that suffers partially observability. The default is 1 meaning that all the sample curves are partially observed. |
Value
a list containing two elements 1) a functional sample and 2) the same sample of functions but partially observed following one of the schemes described in the argument type.
References
Elías, Antonio, Jiménez, Raúl, Paganoni, Anna M. and Sangalli, Laura M. (2020). Integrated Depths for Partially Observed Functional Data.
Examples
data <- sapply(1:100, function(x) runif(1)*sin(seq(0, 2*pi, length.out = 200)) +
runif(1)*cos(seq(0, 2*pi, length.out = 200)))
data_pofd <- intervalPOFD(data, observability = 0.5, ninterval = 2, pIncomplete = 1)
Learning k
Description
This function chooses an optimal parameter k (denoting the number of curves within the envelope that are considered for reconstruction).
Usage
learningK(data, i, J)
Arguments
data |
Data matrix. |
i |
Index of curve. |
J |
Envelope. |
Value
Optimal parameter k.
Outliergram for Partially Observed Functional Data
Description
Plots the Outliergram for PoFD and returns the shape outliers.
Usage
outliergramPOFD(data, fshape = 1.5, p1 = 1, p2 = 0)
Arguments
data |
matrix p by n, being n the number of functions and p the number of grid points. |
fshape |
inflation of the outliergram that determine the shape outlier rule. |
p1 |
parameter of the outliergram for resampling method. Default = 1. |
p2 |
parameter of the outliergram for resampling method. Default = 0. |
Value
a list with the functional outliergram for PoDF and the shape outliers.
References
Arribas-Gil, A. and Romo, J. (2014). Shape outlier detection and visualization for functional data: the outliergram.Biostatistics, 15(4):603–619.
Examples
outliergramPOFD(exampleData$PoFDextremes_outliers, fshape = 1.5, p1 = 1, p2 = 0)
Plot Partially Observed Functional Data
Description
Plot the sample of partially observed curves and the proportion of observed functions.
Usage
plotPOFD(data)
Arguments
data |
matrix p by n, being n the number of functions and p the number of grid points. |
Value
Plot of the partially observed functional data and the proportion of observed functions at each time point.
Examples
plotPOFD(exampleData$PoFDextremes)
Sparse Observability
Description
Generates samples of sparse functions. See Elías et al (2020).
Usage
sparsePOFD(data, observability = NULL, pIncomplete = NULL)
Arguments
data |
functional data completely observed. pxn matrix being n the number of curves and p the number og evaluation points. |
observability |
observed proportion of the domain where each function is observed. |
pIncomplete |
number between 0 and 1 related to the proportion of curves that suffers partially observability. The default is 1 meaning that all the sample curves are partially observed. |
Value
a list containing two elements 1) a functional sample and 2) the same sample of functions but partially observed following one of the schemes described in the argument type.
References
Elías, Antonio, Jiménez, Raúl, Paganoni, Anna M. and Sangalli, Laura M. (2020). Integrated Depths for Partially Observed Functional Data.
Examples
data <- sapply(1:100, function(x) runif(1)*sin(seq(0, 2*pi, length.out = 200)) +
runif(1)*cos(seq(0, 2*pi, length.out = 200)))
data_pofd <- sparsePOFD(data, observability = 0.5, pIncomplete = 1)