Learn R Programming

RelValAnalysis (version 1.0)

SimMarketModel: Simulating a Market Model

Description

The function SimMarketModel is used to simulate a market model defined by a marketmodel object. The output is a toymkt object with which further analysis can be performed.

Usage

SimMarketModel(model, n.years = 10, frequency = 12,
               initial.weight = rep(1/model$n, model$n),
               sub.freq = 1)

Arguments

Value

A toymkt object containing the simulated market. For this object buy.and.hold is TRUE.

Details

The function SimMarketModel simulates a given market model with user-defined parameters. See marketmodel for the definition of a market model. The option sub.freq does the following. Suppose we set frequency = 12 and sub.freq = 4. Although the output is monthly prices, during the simulation, for each month the algorithm divides in month into 4 subperiods (say 4 weeks). In other words, the actual time step in the simulation is dt = 1 / frequency * subfreq, and the output shows only the prices sampled monthly. This feature allows more accurate simulation of rank-based models, where multiple changes in rankings can happen within each sampling period. When the aim is to simulate the evolution of capital distribution curves, the initial market weights play an important role. The default option is equal-weighting. To start the market at stationarity, there are three ways to proceed: 1) Remove an initial segment of the output. 2) Perform two simulations, where in the second simulation the market is started at the ending distribution of the first simulation. 3) Use the long term distribution (say Pareto with a certain slope parameter) directly if it is known. A possibility is to use ParetoCapDist.

See Also

AtlasModel, marketmodel, VolStabModel

Examples

Run this code
# Create an Atlas model of 5 stocks
model <- AtlasModel(n = 5, g = 0.05, sigma = 0.1)

# Simulate the model to get 20 years of monthly data
# with initial weights c(0.1, 0.2, 0.2, 0.2, 0.3)
market <- SimMarketModel(model, n.years = 20, 
                          initial.weight = c(0.1, 0.2, 0.2, 0.2, 0.3), 
                          frequency = 12)
plot(market)

Run the code above in your browser using DataLab