% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fboxcox.R
\name{predict.f_boxcox}
\alias{predict.f_boxcox}
\title{Predict method for f_boxcox objects}
\usage{
\method{predict}{f_boxcox}(object, newdata, inverse = FALSE, ...)
}
\arguments{
\item{object}{An object of class \code{f_boxcox}, as returned by
\code{\link{f_boxcox}}.}

\item{newdata}{A numeric vector of values to transform. For the forward
transform (\code{inverse = FALSE}), all values must be strictly positive
(Box-Cox requires \eqn{y > 0}). For the inverse transform
(\code{inverse = TRUE}), values are assumed to be on the Box-Cox
transformed scale.}

\item{inverse}{Logical. If \code{FALSE} (default), applies the forward
Box-Cox transformation to \code{newdata} using the estimated \eqn{\lambda}
from the original fit. If \code{TRUE}, reverses the transformation, mapping
values from the Box-Cox scale back to the original scale. Default is \code{FALSE}.}

\item{...}{Further arguments passed to or from other methods (currently
unused).}
}
\value{
A numeric vector of the same length as \code{newdata}, containing
  either the forward-transformed or back-transformed values.
}
\description{
Applies the fitted Box-Cox transformation to new data (forward transform),
or reverses it back to the original scale (inverse transform). This is
useful for transforming hypothesis test parameters (e.g., \code{mu}) to the
transformed scale, or for back-transforming confidence intervals to the
original scale.
}
\details{
The forward transformation applies the standard Box-Cox formula:
\deqn{y(\lambda) = \begin{cases}
  \frac{y^\lambda - 1}{\lambda}, & \lambda \neq 0 \\
  \log(y),                       & \lambda = 0
\end{cases}}

The inverse transformation reverses this process to recover the original scale:
\deqn{y = \begin{cases}
  (y(\lambda) \cdot \lambda + 1)^{1/\lambda}, & \lambda \neq 0 \\
  \exp(y(\lambda)),                           & \lambda = 0
\end{cases}}

\strong{Note on inverse validity:} When \eqn{\lambda > 0}, not all
transformed-scale values have a valid inverse. If
\eqn{y(\lambda) \cdot \lambda + 1 \leq 0}, the result is undefined and
\code{NaN} is returned with a warning.
}
\examples{
# Assuming mtcars is available and f_boxcox is loaded
bc <- f_boxcox(mtcars$hp)

# Forward: transform a hypothesis value (mu) to the Box-Cox scale
mu <- 100
mu_transformed <- predict(bc, newdata = mu)

# Inverse: back-transform a confidence interval to the original scale
ci_transformed <- c(5.5, 6.8)
predict(bc, newdata = ci_transformed, inverse = TRUE)

# Round-trip sanity check should return exactly mu (e.g., 100)
predict(bc, newdata = mu_transformed, inverse = TRUE)

}
\seealso{
\code{\link{f_boxcox}}
}
