% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diss_correlation.R
\name{diss_correlation}
\alias{diss_correlation}
\title{Correlation dissimilarity method constructor}
\usage{
diss_correlation(ws = NULL, center = TRUE, scale = FALSE)
}
\arguments{
\item{ws}{Either \code{NULL} (default) or an odd integer greater than 2.
When \code{NULL}, standard Pearson correlation dissimilarity is used.
When an odd integer is provided, a moving (rolling) correlation
dissimilarity is computed using a window of that size.}

\item{center}{Logical. Should the data be mean-centered before computing
dissimilarities? Centering is applied jointly to \code{Xr} and \code{Xu}
(if provided) based on their combined column means. Default is \code{TRUE}.}

\item{scale}{Logical. Should the data be scaled (divided by column standard
deviations) before computing dissimilarities? Scaling is applied jointly
to \code{Xr} and \code{Xu} (if provided). Default is \code{FALSE}.}
}
\value{
An object of class \code{c("diss_correlation", "diss_method")} — a
list holding the validated method parameters. Intended to be passed to
\code{dissimilarity()}, not used directly.
}
\description{
Creates a configuration object that fully specifies a correlation (or moving
correlation) dissimilarity method. Pass the result to \code{dissimilarity()}
to compute the dissimilarity matrix.
}
\details{
The correlation dissimilarity between two observations \eqn{x_i} and
\eqn{x_j} is:

\deqn{d(x_i, x_j) = \frac{1}{2}(1 - \rho(x_i, x_j))}

where \eqn{\rho} is the Pearson correlation coefficient. This is used when
\code{ws = NULL}.

When \code{ws} is specified, the moving correlation dissimilarity is:

\deqn{d(x_i, x_j; ws) = \frac{1}{2\,ws} \sum_{k=1}^{p - ws}
  \bigl(1 - \rho(x_{i,(k:k+ws)},\, x_{j,(k:k+ws)})\bigr)}

where \eqn{ws} is the window size and \eqn{p} is the number of variables.
}
\section{Parallel execution}{

The underlying C++ implementation uses OpenMP for parallel computation.
Thread count is controlled by the \code{OMP_NUM_THREADS} environment
variable. To limit threads (e.g., when calling from within a parallel
backend):
\preformatted{
Sys.setenv(OMP_NUM_THREADS = 1)
}
}

\examples{
# Standard correlation dissimilarity
m <- diss_correlation()

# Moving correlation with window size 41
m <- diss_correlation(ws = 41)

# Without centering
m <- diss_correlation(center = FALSE)

}
\seealso{
\code{\link{dissimilarity}}, \code{\link{diss_euclidean}},
\code{\link{diss_mahalanobis}}, \code{\link{diss_cosine}}
}
\author{
\href{https://orcid.org/0000-0002-5369-5120}{Leonardo Ramirez-Lopez}
}
