\Header{tsdiag}{Diagnostic Plots for Time-Series Fits}
\methalias{tsdiag.Arima}{tsdiag}
\methalias{tsdiag.arima0}{tsdiag}
\methalias{tsdiag.StructTS}{tsdiag}
\keyword{ts}{tsdiag}
\begin{Description}\relax
A generic function to plot time-series diagnostics.
\end{Description}
\begin{Usage}
\begin{verbatim}
tsdiag(object, gof.lag, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] a fitted time-series model
\item[\code{gof.lag}] the maximum number of lags for a Portmanteau
goodness-of-fit test
\item[\code{...}] further arguments to be passed to particular methods
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This is a generic function. It will generally plot the residuals,
often standadized, the autocorrelation function of the residuals, and
the p-values of a Portmanteau test for all lags up to \code{gof.lag}.

The methods for \code{\Link{arima}} and \code{\Link{StructTS}} objects
plots residuals scaled by the estimate of their (individual) variance,
and use the Ljung--Box version of the portmanteau test.
\end{Details}
\begin{Value}
None. Diagnostics are plotted.
\end{Value}
\begin{SeeAlso}\relax
\code{\Link{arima}}, \code{\Link{StructTS}}, \code{\Link{Box.test}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Not run: data(lh)
fit <- arima(lh, c(1,0,0))
tsdiag(fit)

## see also examples(arima)

data(JohnsonJohnson)
(fit <- StructTS(log10(JohnsonJohnson), type="BSM"))
tsdiag(fit)
## End(Not run)\end{ExampleCode}
\end{Examples}

