\HeaderA{lm.fit}{Fitter Functions for Linear Models}{lm.fit}
\aliasA{lm.wfit}{lm.fit}{lm.wfit}
\keyword{regression}{lm.fit}
\keyword{array}{lm.fit}
\begin{Description}\relax
These are the basic computing engines called by \code{\LinkA{lm}{lm}} used
to fit linear models.  These should usually \emph{not} be used
directly unless by experienced users.
\end{Description}
\begin{Usage}
\begin{verbatim}
lm.fit (x, y,    offset = NULL, method = "qr", tol = 1e-7,
       singular.ok = TRUE, ...)

lm.wfit(x, y, w, offset = NULL, method = "qr", tol = 1e-7,
        singular.ok = TRUE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] design matrix of dimension \code{n * p}.
\item[\code{y}] vector of observations of length \code{n}, or a matrix with
\code{n} rows.
\item[\code{w}] vector of weights (length \code{n}) to be used in the fitting
process for the \code{wfit} functions.  Weighted least squares is
used with weights \code{w}, i.e., \code{sum(w * e\textasciicircum{}2)} is minimized.
\item[\code{offset}] numeric of length \code{n}).  This can be used to
specify an \emph{a priori} known component to be included in the
linear predictor during fitting.
\item[\code{method}] currently, only \code{method="qr"} is supported.
\item[\code{tol}] tolerance for the \code{\LinkA{qr}{qr}} decomposition.  Default
is 1e-7.
\item[\code{singular.ok}] logical. If \code{FALSE}, a singular model is an
error.
\item[\code{...}] currently disregarded.
\end{ldescription}
\end{Arguments}
\begin{Value}
a list with components
\begin{ldescription}
\item[\code{coefficients}] \code{p} vector
\item[\code{residuals}] \code{n} vector or matrix
\item[\code{fitted.values}] \code{n} vector or matrix
\item[\code{effects}] (not null fits)\code{n} vector of orthogonal single-df
effects.  The first \code{rank} of them correspond to non-aliased
coeffcients, and are named accordingly.
\item[\code{weights}] \code{n} vector --- \emph{only} for the \code{*wfit*}
functions.
\item[\code{rank}] integer, giving the rank
\item[\code{df.residual}] degrees of freedom of residuals
\item[\code{qr}] (not null fits) the QR decomposition, see \code{\LinkA{qr}{qr}}.
\end{ldescription}
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{lm}{lm}} which you should use for linear least squares regression,
unless you know better.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
set.seed(129)
n <- 7 ; p <- 2
X <- matrix(rnorm(n * p), n,p) # no intercept!
y <- rnorm(n)
w <- rnorm(n)^2

str(lmw <- lm.wfit(x=X, y=y, w=w))

str(lm. <- lm.fit (x=X, y=y))

\end{ExampleCode}
\end{Examples}

