POIFD

Overview

Software to compute Integrated Depth for Partially Observed Functional Data and applications

It implements the proposed depth measures, functional boxplot, functional outliergram for partially observed functional data and reconstruction methods.

Installation

#install the package
# devtools::install_github("aefdz/fdaPOIFD")
install.packages("fdaPOIFD", repos = c('https://aefdz.r-universe.dev', 'https://cloud.r-project.org'))

#load the package
library(fdaPOIFD)

Test usage

#plot the data sets
plot_interval <- plotPOFD(exampleData$PoFDintervals)
plot_common <- plotPOFD(exampleData$PoFDextremes)

plot_interval
## Warning: Removed 2914 rows containing missing values or values outside the scale range
## (`geom_line()`).

## Warning: Removed 9900 rows containing missing values or values outside the scale range
## (`geom_point()`).
plot_common
## Warning: Removed 7368 rows containing missing values or values outside the scale range
## (`geom_line()`).

## Warning: Removed 7368 rows containing missing values or values outside the scale range
## (`geom_point()`).

Computing depths

Example with partially observed common domain. Data is in a matrix form:

mbd <- POIFD(exampleData$PoFDintervals, type = "MBD")

(median <- which.max(mbd)) # deepest curve
## 45 
## 45

Example without partially observed common domain. It implements an step to estimate the observation domain. Data is in a list form:

exampleData$PoFDintervals_list[[1]]
## $x
## [1] 0.000000000 0.005050505 0.010101010
## 
## $y
## [1] 0.7814341 0.7939221 0.8063511

To compute the POIFD, we need to include the vector where the data should be evaluated:

mbd <- POIFD(exampleData$PoFDintervals_list, type = "MBD", t = seq(0, 1, length.out = 100))

(median <- which.max(mbd)) # deepest curve
## 44 
## 44

Functional Boxplot and magnitude outliers

fboxplot <- boxplotPOFD(exampleData$PoFDextremes_outliers, centralRegion = 0.5, fmag = 1.5, fdom = 1)

fboxplot$magnitude
## 102 
## 102
fboxplot$domain
## 102 
## 102
fboxplot$fboxplot
## Warning: Removed 27 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 27 rows containing missing values or values outside the scale range
## (`geom_line()`).

Functional Outliergram and Shape Outliers

outliergram <- outliergramPOFD(exampleData$PoFDextremes_outliers)

outliergram$shape
## [1] 103 104
outliergram$outliergram

Depth-based Reconstruction of Partially Observed Functional data

It implements a reconstruction method based on the partially observed functional depth and the algorithm proposed in Elías, A., Jiménez, R. and Shang, HL. (2022).

data <- exampleData$PoFDintervals
recons_data <- depthbasedreconstructionPOFD(data, id_recons = c(1:2))

par(mfrow = c(1,2))
matplot(data[,1:2], col = c("blue", "red"), type ="l", lty = 1, main = "POFD", ylab = "Y")

matplot(data[,1:2], col = c("blue", "red"), type ="l", lty = 1, main = "Reconstruction", ylab = "Y")
matplot(recons_data, col = c("blue", "red"), add = TRUE, type = "l", lty = 2, main = "Reconstruction", ylab = "Y")

par(mfrow = c(1,1))

References