% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/s3.R
\name{predict.varimaxes}
\alias{predict.varimaxes}
\title{Project new data into PCA score space}
\usage{
\method{predict}{varimaxes}(object, newdata, ...)
}
\arguments{
\item{object}{Fitted \code{varimaxes} or \code{tmfast} object}

\item{newdata}{Document-term matrix (observations x terms) to project}

\item{...}{Not used; included for S3 method compatibility.}
}
\value{
Matrix of PCA scores (n_obs x max_k)
}
\description{
Project new data into PCA score space
}
\details{
Projects \code{newdata} through the PCA rotation stored in \code{object}, returning
raw PCA scores (not varimax scores). Intended for use in pipelines that combine
new data with an existing fitted model (e.g., \code{insert_topics()}). Fragile: \code{newdata}
must share the vocabulary of the training DTM, and the centering/scaling stored in
\code{object} must match how the training data was prepared.

\strong{Memory warning}: \code{scale()} coerces sparse matrices to dense. For large DTMs,
this can be a substantial memory hazard. This mirrors the behavior of \code{prcomp_irlba}
itself, which is why PCA scores are computed once at fit time and not re-projected
on demand.
}
\examples{
\donttest{
set.seed(42)
theta   = rdirichlet(50, 1, k = 3)
phi     = rdirichlet(3, 0.1, k = 20)
corpus  = draw_corpus(rep(50L, 50), theta, phi)
model   = tmfast(corpus, n = 3)
theta2  = rdirichlet(5, 1, k = 3)
newdocs = draw_corpus(rep(200L, 5), theta2, phi) |>
    tidytext::cast_sparse(doc, word, n)
predict(model, newdocs)
}
}
