Description Usage Arguments Details Value Author(s) See Also Examples
Test a portfolio allocation on a new data set. This function is useful for comparing portfolios under different data scenarios.
1 2 |
theData |
The data set to be used. This may be an object of class |
model |
An object of class |
X |
The stock allocation of the portfolio, where element |
newestFirst |
If argument |
isReturns |
If argument |
When the argument X
is used or if theData
is not from getReturns
, provide column names to theData
that correspond with the names of the elements of X
. If theData
is a vector of one plus the returns of each stock, then this vector should have its element names corresponding to those elements in X
.
If theData
is an object of class "stockReturns"
or is a matrix of returns or prices, then this will allow the resulting object of class "testPort"
to be plotted. See the examples for details.
testPort
outputs an object of class "testPort"
, which consists of the following items:
X |
The allocation used. |
sumRet |
Summary of the returns for each stock. |
change |
The value of the portfolio if it started at 1. |
returns |
Return data, if provided. |
David Diez and Nicolas Christou
getReturns
, stockModel
, optimalPort
, portReturn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #===> build two single index models <===#
data(stock99)
data(stock94Info)
non <- stockModel(stock99, drop=25, model='none', industry=stock94Info$industry)
sim <- stockModel(stock99, model='SIM', industry=stock94Info$industry, index=25)
ccm <- stockModel(stock99, drop=25, model='CCM', industry=stock94Info$industry)
mgm <- stockModel(stock99, drop=25, model='MGM', industry=stock94Info$industry)
#===> build optimal portfolios <===#
opNon <- optimalPort(non)
opSim <- optimalPort(sim)
opCcm <- optimalPort(ccm)
opMgm <- optimalPort(mgm)
#===> test portfolios on 2004-9 <===#
data(stock04)
tpEqu <- testPort(stock04[,-25], X=rep(1,24)/24)
tpNon <- testPort(stock04, opNon)
tpSim <- testPort(stock04, opSim)
tpCcm <- testPort(stock04, opCcm)
tpMgm <- testPort(stock04, opMgm)
print(tpEqu)
summary(tpEqu)
#===> compare performances <===#
plot(tpEqu, ylim=c(1, 3))
lines(tpNon, col=2, lty=2)
lines(tpSim, col=3, lty=3)
lines(tpCcm, col=4, lty=4)
# a sample of how to use points on an object of
# class "testPort", however, its use makes the
# plot somewhat ugly
points(tpMgm, col=5, lty=5, type='b')
legend('topleft', col=1:5, lty=1:5, legend=c('equal all.', 'none', 'SIM', 'CCM', 'MGM'), pch=c(NA, NA, NA, NA, 1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.