Last chance! 50% off unlimited learning
Sale ends in
"stockReturns"
and select a model. Available choices are "none"
, "SIM"
(single index model), "CCM"
(constant correlation model), and "MGM"
(multigroup model).
stockModel(stockReturns, drop = NULL, Rf = 0, shortSelling = c("y", "n"), model = c("none", "SIM", "CCM", "MGM"), industry = NULL, index = NULL, get = c("overlapOnly", "all"), freq = c("month", "week", "day"), start = "1970-01-01", end = NULL, recentLast = FALSE, rawStockPrices = FALSE)
"stockReturns"
. Additionally, a character vector of tickers can also be used here, in which case also see argument freq
, get
, start
, and end
. Additionally, an object of class "stockModel"
can also be input here, which will permit model adjustments, including switching the model altogether. Finally, stock data can also be submitted here as a matrix; the column names should be the ticker names and the row names should be the dates of the returns, YYYY-MM-DD
. Additionally, for outside data sets where the oldest stock return is in row 1 (and not the last row), see argument recentLast
."none"
, "CCM"
, or "MGM"
is used, stock indices might be dropped.Rf=0.02/12
, or 2% with daily data would imply Rf=0.02/250
if there are 250 trading days per year.). The default value is 0."yes"
(default) or "no"
. Some models, "none"
and "MGM"
, will permit short-selling regardless of this selection."none"
, the default), the single index model ("SIM"
), constant correlation model ("CCM"
), or the multigroup model ("MGM"
).model="MGM"
, however, it may be included in any model for slightly enhanced graphics.model="SIM"
, the index
is the column number indicating the stock index. Warning if using drop
and also specifying the index: The value of index
should correspond to the column number AFTER dropping columns. See Details below."overlapOnly"
(default) obtains stock returns for which all stocks had data and drops any dates with NA
. "all"
yields all stock returns regardless of whether data for all stocks is available. This argument is ignored unless stockReturns
is a vector of tickers."month"
and other options are "week"
and "day"
. This argument is ignored unless stockReturns
is a vector of tickers."YYYY-MM-DD"
. This argument is ignored unless stockReturns
is a vector of tickers."YYYY-MM-DD"
. This argument is ignored unless stockReturns
is a vector of tickers.TRUE
if (1) you are using your own data that was not obtained by getReturns
and (2) your matrix of returns runs from oldest returns (row 1) to most recent returns (last row).TRUE
if (1) you are using your own data that was not obtained by getReturns
and (2) your matrix is of stock prices and not of stock returns.stockModel
outputs an object of class "stockModel"
, which is a list of the following items, many of which might be NA
:
COV
).alpha
.beta
.adjustBeta
.model="MGM"
, the matrix of averaged correlations. See getCorr
.If stocks are dropped using the argument drop
, then index
must correspond to the position of the index AFTER those stocks are dropped. For instance, if there are seven stocks, the index is in position six, and the fourth stock is dropped, then we should use index=5
.
Elton, Edwin, J., Gruber, Martin, J., Padberg, Manfred, W. "Simple Criteria for Optimal Portfolio Selection," Journal of Finance, XI, No. 5 (Dec. 1976), pp. 1341-1357.
Elton, Edwin, J., Gruber, Martin, J., Padberg, Manfred, W. "Simple Rules for Optimal Portfolio Selection: The Multi Group Case," Journal of Financial and Quantitative Analysis, XII, No. 3 (Sept. 1977), pp. 329-345.
Elton, Edwin, J., Gruber, Martin, J., Padberg, Manfred, W. "Simple Criteria for Optimal Portfolio Selection: Tracing Out the Efficient Frontier," Journal of Finance, XIII, No. 1 (March 1978), pp. 296-302.
getReturns
, adjustBeta
, optimalPort
, testPort
#===> build four 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)
tpNon <- testPort(stock04, opNon)
tpSim <- testPort(stock04, opSim)
tpCcm <- testPort(stock04, opCcm)
tpMgm <- testPort(stock04, opMgm)
#===> compare performances <===#
plot(tpNon)
lines(tpSim, col=2, lty=2)
lines(tpCcm, col=3, lty=3)
lines(tpMgm, col=4, lty=4)
legend('topleft', col=1:4, lty=1:4, legend=c('none', 'SIM', 'CCM', 'MGM'))
Run the code above in your browser using DataLab