% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Partial_Moments.R
\name{PM.matrix}
\alias{PM.matrix}
\title{Partial Moment Matrix}
\usage{
PM.matrix(LPM_degree, UPM_degree, target, variable, pop_adj, norm = FALSE)
}
\arguments{
\item{LPM_degree}{numeric; lower partial moment degree (0 = freq, 1 = area).}

\item{UPM_degree}{numeric; upper partial moment degree (0 = freq, 1 = area).}

\item{target}{numeric vector; thresholds for each column (defaults to colMeans).}

\item{variable}{numeric matrix or data.frame.}

\item{pop_adj}{logical; TRUE adjusts population vs. sample moments.}

\item{norm}{logical; default FALSE. If TRUE, each quadrant matrix is cell-wise normalized so their sum is 1 at each (i,j).}
}
\value{
A list: $cupm, $dupm, $dlpm, $clpm, $cov.matrix.
}
\description{
Builds a list containing CUPM, DUPM, DLPM, CLPM and the overall covariance matrix.
}
\details{
Partial Moment Matrix
}
\note{
When \code{norm = TRUE}, each cell (i,j) of the four quadrant matrices
is normalized so that their sum equals 1.  In this case, 
\code{$cov.matrix} is computed as 
\code{$cupm + $clpm - $dupm - $dlpm}, yielding a dimensionless,
signed dependence measure bounded between -1 and 1.
This representation discards magnitude information and is therefore
a lossy nonlinear correlation matrix.  A higher fidelity nonlinear
correlation matrix is available via the \code{NNS.dep} function.
}
\examples{
set.seed(123)
A <- cbind(rnorm(100), rnorm(100), rnorm(100))

# Uses norm = FALSE by default
PM.matrix(1, 1, target = NULL, variable = A, pop_adj = TRUE)

# Enable normalization
PM.matrix(1, 1, target = NULL, variable = A, pop_adj = TRUE, norm = TRUE)

# Use 0's for targets
PM.matrix(1, 1, target = rep(0, ncol(A)), variable = A, pop_adj = TRUE)        

# Use variable medians as targets
PM.matrix(1, 1, target = apply(A, 2, "median"), variable = A, pop_adj = TRUE)  
}
