% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/align.R
\name{matchalign}
\alias{matchalign}
\title{MatchAlign post-processing for partition-model draws}
\usage{
matchalign(fit, pivot = NULL)
}
\arguments{
\item{fit}{A fit carrying draw arrays \code{F} (\verb{[T, J, K]}), \code{Lambda}
(\verb{[T, N, K]}), \code{sigma} (\verb{[T, K]}), and \code{K}.}

\item{pivot}{Optional draw index to use as the alignment pivot. \code{NULL}
(the default) selects the draw whose loading condition number sits at
the median.}
}
\value{
The fit with aligned \code{F}, \code{Lambda}, and \code{sigma}, and the chosen
\code{pivot} index appended.
}
\description{
Resolves rotational, sign, and label-permutation ambiguity in posterior
draws by the MatchAlign procedure of Poworoznek et al. (2025), adapted to
the partition model: varimax rotation of the loadings per draw, a pivot
draw at the median condition number (overridable), pivot polarity fixed
so each factor's loadings skew positive (defining sorts load positively),
greedy signed matching of loading columns to the pivot, and a
Procrustes rotation. A final pass re-orients every draw to the varimax
of the aligned mean loadings, re-signed to positive skew, so the
delivered orientation does not inherit one draw's sampling noise. One
rotation is applied to loadings and scores alike, and the loading scale
\code{sigma} is carried through.

Called for its side effect on the draw arrays of an engine-level fit;
users normally receive already-aligned draws from \code{\link[=fit_bayesian]{fit_bayesian()}} and
need this only to realign under a different pivot.
}
\references{
Poworoznek, E., Anceschi, N., Ferrari, F., & Dunson, D. (2025).
Efficiently Resolving Rotational Ambiguity in Bayesian Matrix
Sampling with Matching. \emph{Bayesian Analysis}.
}
