% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fm_depth.R
\name{fm_depth}
\alias{fm_depth}
\title{Fraiman-Muniz Functional Depth}
\usage{
fm_depth(X, grid = NULL, type = c("tukey", "simplicial"))
}
\arguments{
\item{X}{Numeric matrix of dimension \eqn{N \times M}, where rows are curves
and columns are time points.  Missing values are not allowed.}

\item{grid}{Numeric vector of length \eqn{M} giving the observation times
(e.g. \code{seq(0, 1, length.out = M)}).  If \code{NULL} (default) equally spaced
points on \eqn{[0, 1]} are assumed.}

\item{type}{Character string, either \code{"tukey"} (default) or \code{"simplicial"},
selecting the univariate depth used at each time point.}
}
\value{
A numeric vector of length \eqn{N} containing the FM depth value
for each curve.
}
\description{
Computes the Fraiman-Muniz (FM) depth for a collection of discretised
functional observations. Two variants are supported: the Tukey-FM depth,
which maps depth values to \eqn{[0, 1]}, and the Simplicial-FM depth,
which maps to \eqn{[0.5, 1]}.  The two are related by
\deqn{\text{Tukey-FM}_i = 2\,(\text{Simplicial-FM}_i - 1/2).}
}
\details{
For a discretised dataset \eqn{\{x_i(t_j)\}}, \eqn{i = 1,\ldots,N},
\eqn{j = 1,\ldots,M}, the Simplicial-FM depth is
\deqn{
  \text{FM}_i = \sum_{j=2}^{M}(t_j - t_{j-1})
  \left[1 - \left|\frac{1}{2} - F_{N,t_j}(x_i(t_j))\right|\right],
}
where \eqn{F_{N,t}} is the empirical CDF of the sample at time \eqn{t}.
The Tukey-FM depth substitutes the Tukey univariate depth
\eqn{\min\{F_{N,t}(x), 1 - F_{N,t}(x)\}} at each time point.
}
\examples{
set.seed(1)
N <- 50; M <- 100
X <- matrix(rnorm(N * M), nrow = N)
d <- fm_depth(X)
plot(d, xlab = "Curve index", ylab = "Tukey-FM depth")

}
\references{
Fraiman, R. and Muniz, G. (2001). Trimmed means for functional data.
\emph{Test}, \strong{10}(2), 419–440.

López-Pintado, S. and Romo, J. (2009). On the concept of depth for
functional data. \emph{Journal of the American Statistical Association},
\strong{104}(486), 718–734.
}
