% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/classifiers.R
\name{gam_depth_classify}
\alias{gam_depth_classify}
\alias{print.fd_gam_fit}
\title{GAM Classifier on Signed Depth}
\usage{
gam_depth_classify(
  X_train,
  y_train,
  X_test = NULL,
  covariates = c("sdp", "sdp+mode"),
  k_gam = 10L,
  n_pc = 10L,
  downweight = FALSE,
  max_iter = 10L,
  grid = NULL,
  type = c("tukey", "simplicial")
)

\method{print}{fd_gam_fit}(x, ...)
}
\arguments{
\item{X_train}{Numeric matrix (\eqn{N \times M}).}

\item{y_train}{Integer vector of labels (0/1).}

\item{X_test}{Numeric matrix. If \code{NULL} the training set is used.}

\item{covariates}{Character: \code{"sdp"} (default) or \code{"sdp+mode"}
to include a second smooth on the signed distance to the mode.}

\item{k_gam}{Basis dimension for \code{\link[mgcv]{s}}. Default \code{10}.}

\item{n_pc}{Number of PCs for mode estimation. Default \code{10}.}

\item{downweight}{Logical; if \code{TRUE} iterate with outlier
down-weighting. Default \code{FALSE}.}

\item{max_iter}{Maximum down-weighting iterations. Default \code{10}.}

\item{grid}{Numeric vector of length \eqn{M}.}

\item{type}{Depth variant.}

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

\item{...}{Ignored.}
}
\value{
An object of class \code{"fd_gam_fit"} with components:
\describe{
\item{predicted}{Predicted class labels.}
\item{prob}{Matrix with columns \code{prob_0} and \code{prob_1}.}
\item{gam_fit}{The fitted \code{\link[mgcv]{gam}} object.}
\item{sd_train}{The \code{"fd_signed_depth"} object for the training
set.}
\item{covariates}{Character: covariates used.}
}

Invisibly returns \code{x}.
}
\description{
Fits a generalised additive model (GAM) with a smooth term on the signed
depth to estimate class membership probabilities. An optional iterative
outlier down-weighting scheme is available (Section 3.8 of Perez Ruiz,
2020).
}
\examples{
set.seed(17)
M <- 80; N <- 100
t  <- seq(0, 1, length.out = M)
X0 <- t(replicate(50, sin(2 * pi * t) + rnorm(M, sd = 0.4)))
X1 <- t(replicate(50, cos(2 * pi * t) + rnorm(M, sd = 0.4)))
X  <- rbind(X0, X1)
y  <- rep(0:1, each = 50)
fit <- gam_depth_classify(X, y)
print(fit)

}
