\HeaderA{ls.diag}{Compute Diagnostics for `lsfit' Regression Results}{ls.diag}
\keyword{regression}{ls.diag}
\begin{Description}\relax
Computes basic statistics, including standard errors, t- and p-values
for the regression coefficients.
\end{Description}
\begin{Usage}
\begin{verbatim}
ls.diag(ls.out)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{ls.out}] Typically the result of \code{\LinkA{lsfit}{lsfit}()}
\end{ldescription}
\end{Arguments}
\begin{Value}
A \code{list} with the following numeric components.
\begin{ldescription}
\item[\code{std.dev}] The standard deviation of the errors, an estimate of
\eqn{\sigma}{sigma}.
\item[\code{hat}] diagonal entries \eqn{h_{ii}}{} of the hat matrix \eqn{H}{}
\item[\code{std.res}] standardized residuals
\item[\code{stud.res}] studentized residuals
\item[\code{cooks}] Cook's distances
\item[\code{dfits}] DFITS statistics
\item[\code{correlation}] correlation matrix
\item[\code{std.err}] standard errors of the regression coefficients
\item[\code{cov.scaled}] Scaled covariance matrix of the coefficients
\item[\code{cov.unscaled}] Unscaled covariance matrix of the coefficients
\end{ldescription}
\end{Value}
\begin{References}\relax
Belsley, D. A., Kuh, E. and Welsch, R. E. (1980)
\emph{Regression Diagnostics.}
New York: Wiley.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{hat}{hat}} for the hat matrix diagonals,
\code{\LinkA{ls.print}{ls.print}},
\code{\LinkA{lm.influence}{lm.influence}}, \code{\LinkA{summary.lm}{summary.lm}},
\code{\LinkA{anova}{anova}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

##-- Using the same data as the lm(.) example:
lsD9 <- lsfit(x = as.numeric(gl(2, 10, 20)), y = weight)
dlsD9 <- ls.diag(lsD9)
utils::str(dlsD9, give.attr=FALSE)
abs(1 - sum(dlsD9$hat) / 2) < 10*.Machine$double.eps # sum(h.ii) = p
plot(dlsD9$hat, dlsD9$stud.res, xlim=c(0,0.11))
abline(h = 0, lty = 2, col = "lightgray")
\end{ExampleCode}
\end{Examples}

