mrfDepth (version 1.0.12)

mfdmedian: Multivariate functional median for functional data.

Description

Computes the multivariate functional median, an estimate for the central tedency for multivariate functional data.

Usage

mfdmedian(x, type="hdepth", crossDepthsX = NULL,
            depthOptions = NULL, centerOption = "maxdepth")

Arguments

x

A three dimensional \(t\) by \(n\) by \(p\) array, with \(t\) the number of observed time points, \(n\) the number of functional observations and \(p\) the number of measurements for every functional observation at every time point.

type

The depth used in the computations. One of the following options: "hdepth", "projdepth", "sprojdepth", "dprojdepth", "sdepth". Defaults to "hdepth".

crossDepthsX

Depths at each time point. Can be used to save time

depthOptions

A list of options to pass to the function calculating the cross-sectional depths. See hdepth, projdepth, sprojdepth, dprojdepth or sdepth.

centerOption

By default the 'maxdepth' center estimate is used for the projmedian and the sprojmedian. This can be changed by setting centerOption to 'gravity' or 'Huber' depending on wheter projmedian or sprojmedian is used.

Value

A list with the following component:

MFDmedian

An (txp) matrix containing the estimated central curve.

IndFlagExactFit

Vector containing the indices of the time points for which an exact fit is detected.

Details

The multivariate functional median a multivariate functional data set is defined as the multivariate curve connecting the cross-sectional multivariate depth medians (Claeskens et al., 2014). The MFD median can be computed in all dimensions \(p\) using halfspace depth, projection depth and skewness-adjusted projection depth.

It is possible that at certain time points a part of the algorithm can not be executed due to e.g. exact fits. In that case the estimate for the center will be set to NaN. A warning is issued at the end of the algorithm to signal these time points. Furthermore the output contains an extra argument giving the indices of the time points where problems occured.

References

Claeskens G., Hubert M., Slaets L., Vakili K. (2014). Multivariate functional halfspace depth. Journal of the American Statistical Association, 109, 505, 411--423.

Examples

Run this code
# NOT RUN {
# We will illustrate the function using a bivariate functional sample.
data(characterA)
Data <- characterA[,1:50,]
Result <- mfdmedian(Data)

par(mfrow = c(1,2))
matplot(Data[,,1], type = "l", col = "black", lty = 1, ylab = "x-coordinate")
matlines(Result$MFDmedian[,1], type = "l", col = "red", lty = 1)
matpoints(Result$MFDmedian[,1], col = "red", pch = 15)
matplot(Data[,,2], type = "l", col = "black", lty = 1, ylab = "y-coordinate")
matlines(Result$MFDmedian[,2], type = "l", col = "red", lty = 1)
matpoints(Result$MFDmedian[,2], col = "red", pch = 15)
par(mfrow = c(1,1))

# Other depth function such as adjusted outlyingness may also 
# used to determine the cross-sectional depth median. 
# In this case the depth median is calculated by the 
# sprojmedian routine. 
# When different depth median are available, a specific depth
# median can be selected usinf the centerOption. Optional 
# arguments used by the sprojmedian routine may be specified
# using the depthOptions. For example one might choose the
# "Rotation" equivariance for 300 directions. 
Result <- mfdmedian(Data, type = "sprojdepth",
                    depthOptions = list(type = "Rotation",
                                        ndir = 300),
                    centerOption = "gravity")
par(mfrow = c(1,2))
matplot(Data[,,1], type = "l", col = "black", lty = 1, ylab = "x-coordinate")
matlines(Result$MFDmedian[,1], type = "l", col = "red", lty = 1)
matpoints(Result$MFDmedian[,1], col = "red", pch = 15)
matplot(Data[,,2], type = "l", col = "black", lty = 1, ylab = "y-coordinate")
matlines(Result$MFDmedian[,2], type = "l", col = "red", lty = 1)
matpoints(Result$MFDmedian[,2], col = "red", pch = 15)
par(mfrow = c(1,1))

# If the user already placed a call to the mdf routine
# with the diagnostic options set to TRUE, the 
# mfdmedian can easily be obtained by passing the cross-sectional 
# depths. This drastically saves computing time.  
tResult <- mfd(x = Data, type = "sprojdepth", diagnostic = TRUE)
Result <- mfdmedian(Data, type = "sprojdepth",
                    crossDepthsX = tResult$crossdepthX,
                    centerOption = "gravity")
# }

Run the code above in your browser using DataLab