% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_model_dmodx.R
\name{dmodx}
\alias{dmodx}
\title{Distance to the Model in X-Space (DModX)}
\usage{
dmodx(mod, plot = TRUE)
}
\arguments{
\item{mod}{An OPLS model object of class \code{m8_model} (engine = "opls").}

\item{plot}{Logical. If TRUE, a plot of DModX values with an approximate cutoff is shown.}
}
\value{
A data frame with columns \code{ID}, \code{DmodX}, and \code{passed}.
}
\description{
Calculates the orthogonal distance of each observation to an OPLS model in X-space.
DModX can be used for identifying outliers.
}
\details{
DModX is computed from the X-residual matrix as a scaled RMSE of residuals.
The empirical cutoff (dashed line in plot) uses a t-based confidence interval
and assumes approximate normality of DModX values. This assumption may not be
satisfied in all datasets, so the resulting threshold should be regarded
as a pragmatic heuristic for outlier detection.
}
\examples{
data(covid)
cv <- balanced_mc(k=5, split=2/3)
scaling <- uv_scaling(center=TRUE)
model <-opls(X=covid$X, Y=covid$an$type, scaling, cv)
dX <- dmodx(model)
print(dX[[1]])
df <- dX[[2]]; head(df)

}
\seealso{
Other model_validation: 
\code{\link{cv_anova}()},
\code{\link{opls_perm}()}
}
\concept{model_validation}
