% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pmm_unified_api.R
\name{pmm_lm}
\alias{pmm_lm}
\title{Fit a linear model with the polynomial maximization method}
\usage{
pmm_lm(formula, data, method = c("auto", "pmm2", "pmm3"), ...)
}
\arguments{
\item{formula}{R formula for the model.}

\item{data}{data.frame containing the variables in \code{formula}.}

\item{method}{One of \code{"auto"}, \code{"pmm2"}, or \code{"pmm3"}.
\code{"auto"} consults \code{\link{pmm_dispatch}} and falls back to
PMM2 when the dispatcher recommends OLS, so the return value is
always a \code{\linkS4class{PMMfit}} object.}

\item{...}{Additional arguments forwarded to the underlying fitter
(\code{\link{lm_pmm2}} or \code{\link{lm_pmm3}}).}
}
\value{
An S4 object of class \code{\linkS4class{PMM2fit}} or
\code{\linkS4class{PMM3fit}}, both inheriting from
\code{\linkS4class{PMMfit}}.
}
\description{
Unified entry point for PMM2 and PMM3 linear regression. Dispatches
to \code{\link{lm_pmm2}} or \code{\link{lm_pmm3}} based on the
\code{method} argument. With \code{method = "auto"}, the
\code{\link{pmm_dispatch}} rule is applied to the residuals of an
initial OLS fit to select the recommended method.
}
\examples{
set.seed(123)
n <- 80
x <- rnorm(n)
y <- 2 + 3 * x + rgamma(n, 2, 1) - 2
dat <- data.frame(y = y, x = x)
fit <- pmm_lm(y ~ x, data = dat, method = "pmm2")
fit

}
\seealso{
\code{\link{pmm_dispatch}}, \code{\link{pmm_arima}},
\code{\link{lm_pmm2}}, \code{\link{lm_pmm3}}.
}
