\HeaderA{backtest-class}{Class "backtest"}{backtest.Rdash.class}
\aliasA{ci}{backtest-class}{ci}
\aliasA{ci,backtest-method}{backtest-class}{ci,backtest.Rdash.method}
\aliasA{counts}{backtest-class}{counts}
\aliasA{counts,backtest-method}{backtest-class}{counts,backtest.Rdash.method}
\aliasA{marginals}{backtest-class}{marginals}
\aliasA{marginals,backtest-method}{backtest-class}{marginals,backtest.Rdash.method}
\aliasA{means}{backtest-class}{means}
\aliasA{means,backtest-method}{backtest-class}{means,backtest.Rdash.method}
\aliasA{naCounts}{backtest-class}{naCounts}
\aliasA{naCounts,backtest-method}{backtest-class}{naCounts,backtest.Rdash.method}
\aliasA{plot}{backtest-class}{plot}
\aliasA{plot,backtest,missing-method}{backtest-class}{plot,backtest,missing.Rdash.method}
\aliasA{show,backtest-method}{backtest-class}{show,backtest.Rdash.method}
\aliasA{summary,backtest-method}{backtest-class}{summary,backtest.Rdash.method}
\aliasA{turnover}{backtest-class}{turnover}
\aliasA{turnover,backtest-method}{backtest-class}{turnover,backtest.Rdash.method}
\keyword{classes}{backtest-class}
\begin{Description}\relax
Contains results from the backtest function.
\end{Description}
\begin{Details}\relax
The primary method for accessing the \code{backtest} results is through
the \code{summary} method.  \code{summary} provides different displays
depending on the type of \code{backtest} object.  These displays are
shown in the examples section.  Accessor methods such as \code{means},
\code{counts}, \code{marginals}, \code{naCounts}, \code{turnover}, and
\code{ci} may be used to extract other types of information from the object.

A \code{backtest} object with a \code{natural} value of TRUE may be
graphed by calling the \code{plot} method.  The default \code{plot}
method graphs return.  The other plots, turnover and
cumulative return, must be explicitly specified as \code{plot(object,
  type = "turnover")} or \code{plot(object, type = "cumreturn")}.

The \code{backtest} object does not store the data frame used to create
the \code{backtest.}  It only stores the results and the names of the
vectors used in calculating these results.

The results of a \code{backtest} are stored in a 5-dimensional array,
\code{results}.  The 1st dimension contains one value for every element
of \code{ret.var}.  The 2nd dimension contains one value for
every element of \code{in.var}.  The 3rd dimension contains one value
for every element in \code{1:buckets[1]}, a vector from 1 through the
number of \code{by.var} buckets.  The 4th dimension contains one value
for every element in \code{1:buckets[2]}, a vector from 1 through the
number of \code{in.var} buckets.  The 5th dimension contains 4
elements: \code{means}, \code{counts}, \code{trim.means}, and
\code{NAs}.
\end{Details}
\begin{Section}{Objects from the Class}
Objects can be created by calls to the function \code{backtest(data,
    in.var, ret.var, ...)}.
\end{Section}
\begin{Section}{Slots}
\describe{
\item[\code{in.var}:] Object of class \code{"character"} specifying
the \code{in.var} values for this backtest.

\item[\code{ret.var}:] Object of class \code{"character"} containing
the \code{ret.var} values for this backtest.

\item[\code{by.var}:] Object of class \code{"character"} containing
the \code{by.var}, if specified, for this backtest. 

\item[\code{date.var}:] Object of class \code{"character"} containing
the \code{date.var}, if specified, for this backtest. 

\item[\code{buckets}:] Object of class \code{"numeric"} containing
the number(s) of buckets used create quantiles from the
\code{in.var} and \code{by.var} values.

\item[\code{results}:] A 5-dimensional array containing the results
of the backtest.

\item[\code{rawstats}:] Object of class \code{"data.frame"} containing
some summary statistics for this backtest. 

\item[\code{natural}:] Object of class \code{"logical"} expressing
whether or not the intervals between observations, as specified by
\code{date.var}, and returns, as specified by \code{ret.var},
match.  If the interval between dates is one month, the interval
between returns should also be one month.

}
\end{Section}
\begin{Section}{Methods}
\describe{
\item[show] \code{signature(object = "backtest")}: Prints the
variables used in this backtest.

\item[summary] \code{signature(object = "backtest")}: Prints
the results of the backtest.

\item[means] \code{signature(object = "backtest")}: Returns a list
of matrices, with one matrix for each \code{in.var}, where the
value of each cell is the mean of the returns for that
\code{in.var} and \code{by.var} combination.

\item[counts] \code{signature(object = "backtest")}: Returns a list
of matrices, with one matrix for each \code{in.var}, where the
value of each cell is the number of observations for that
\code{in.var} and \code{by.var} combination.

\item[marginals] \code{signature(object = "backtest")}: Returns a
list of matrices, one matrix for each \code{in.var}, where the
value of each cell is the number of observations for that
\code{in.var} and \code{by.var} combination.  Different from
\code{counts} because the marginal sums have been appended to the
matrices.

\item[naCounts] \code{signature(object = "backtest")}: Returns a
list of matrices, with one matrix for each \code{in.var}, where
the value of each cell is the number of NA observations for that
\code{in.var} and \code{by.var}
combination.

\item[ci] \code{signature(object = "backtest")}: Returns a
matrix of confidence intervals for spreads.


\item[turnover] \code{signature(object = "backtest")}: Returns a
\code{data.frame} of the turnovers if the \code{backtest} is \code{natural}.

\item[plot] \code{signature(x = "backtest", y = "missing")}: Plots
returns, cumulative returns, or turnover, when passed a
\code{type} argument of \code{return}, \code{cumreturn}, or
\code{turnover}, respectively.

}
\end{Section}
\begin{Author}\relax
Kyle Campbell \email{kyle.w.campbell@williams.edu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{backtest}{backtest}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

data(starmine)
bt <- backtest(starmine, in.var = "smi", ret.var = "fwd.ret.1m", by.period = FALSE)

## Summary for a pooled backtest

summary(bt)

## A natural backtest

bt <- backtest(starmine, in.var = "smi", ret.var = "fwd.ret.1m",
               date.var = "date", id.var = "id", natural = TRUE, by.period = FALSE)

## Summary for a natural backtest

summary(bt)

## Other access methods

means(bt)
counts(bt)
marginals(bt)
naCounts(bt)

## Plotting methods

plot(bt, type = "turnover")
plot(bt, type = "return")
plot(bt, type = "cumreturn")

\end{ExampleCode}
\end{Examples}

