% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/signed_depth.R
\name{signed_depth}
\alias{signed_depth}
\alias{print.fd_signed_depth}
\title{Signed Depth}
\usage{
signed_depth(
  X,
  grid = NULL,
  type = c("tukey", "simplicial"),
  x_ref = NULL,
  depth = NULL
)

\method{print}{fd_signed_depth}(x, ...)
}
\arguments{
\item{X}{Numeric matrix (\eqn{N \times M}) with curves in rows.}

\item{grid}{Numeric vector of length \eqn{M}. Defaults to equally spaced
points on \eqn{[0, 1]}.}

\item{type}{Depth variant: \code{"tukey"} (default) or
\code{"simplicial"}.}

\item{x_ref}{Optional pre-computed reference curve (numeric vector of
length \eqn{M}). Computed internally if \code{NULL}.}

\item{depth}{Optional pre-computed FM depth vector of length \eqn{N}.
Computed internally if \code{NULL}.}

\item{x}{A \code{"fd_signed_depth"} object.}

\item{...}{Ignored.}
}
\value{
An object of class \code{"fd_signed_depth"} with components:
\describe{
\item{sdp}{Numeric vector of length \eqn{N}: the signed depths.}
\item{depth}{Numeric vector of length \eqn{N}: raw FM depths.}
\item{sdi}{Numeric vector of length \eqn{N}: signed distance
integrals.}
\item{x_ref}{Numeric vector of length \eqn{M}: reference curve.}
\item{grid}{Numeric vector of length \eqn{M}: time grid used.}
\item{type}{Character: depth variant used.}
\item{N}{Number of curves.}
\item{M}{Number of time points.}
}

Invisibly returns \code{x}.
}
\description{
The core transformation of the k-RNN pipeline. For each curve computes
\deqn{\mathrm{sdp}(x_i(t)) =
  \mathrm{sgn}\!\left\{\int_I(x_i(t)-x_{\mathrm{ref}}(t))\,dt\right\}
  \times D(x_i(t)),}
where \eqn{D(\cdot)} is the Fraiman-Muniz depth and the sign is derived
from the signed distance integral (equation 3.2 of Perez Ruiz, 2020).
Curves above the reference receive a positive signed depth; curves below
receive a negative one.
}
\examples{
set.seed(42)
N <- 60; M <- 100
t  <- seq(0, 1, length.out = M)
X0 <- t(replicate(N / 2, sin(2 * pi * t) + rnorm(M, sd = 0.3)))
X1 <- t(replicate(N / 2, cos(2 * pi * t) + rnorm(M, sd = 0.3)))
X  <- rbind(X0, X1)
sd_obj <- signed_depth(X)
plot(sd_obj$sdp, col = rep(1:2, each = N / 2),
     xlab = "Curve index", ylab = "Signed depth",
     main = "Signed depth by group")
abline(h = 0, lty = 2)

}
\references{
Perez Ruiz, D. A. (2020). \emph{Supervised Classification for Functional
Data}. PhD thesis, University of Manchester.
}
