Learn R Programming

backtest (version 0.2-0)

backtest-class: Class "backtest"

Description

Contains results from the backtest function.

Arguments

Objects from the Class

Objects can be created by calls to the function backtest(data, in.var, ret.var, ...).

Details

The primary method for accessing the backtest results is through the summary method. summary provides different displays depending on the type of backtest object. These displays are shown in the examples section. Accessor methods such as means, counts, marginals, naCounts, turnover, and ci may be used to extract other types of information from the object.

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

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

The results of a backtest are stored in a 5-dimensional array, results. The 1st dimension contains one value for every element of ret.var. The 2nd dimension contains one value for every element of in.var. The 3rd dimension contains one value for every element in 1:buckets[1], a vector from 1 through the number of by.var buckets. The 4th dimension contains one value for every element in 1:buckets[2], a vector from 1 through the number of in.var buckets. The 5th dimension contains 4 elements: means, counts, trim.means, and NAs.

See Also

backtest

Examples

Run this code
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")

Run the code above in your browser using DataLab