Book contents
- Frontmatter
- Dedication
- Contents
- Preface
- Acknowledgments
- 1 Analytical Thinking
- 2 The R Language for Statistical Computing
- 3 Financial Statistics
- 4 Financial Securities
- 5 Dataset Analytics and Risk Measurement
- 6 Time Series Analysis
- 7 The Sharpe Ratio
- 8 Markowitz Mean-Variance Optimization
- 9 Cluster Analysis
- 10 Gauging the Market Sentiment
- 11 Simulating Trading Strategies
- 12 Data Exploration Using Fundamentals
- 13 Prediction Using Fundamentals
- 14 Binomial Model for Options
- 15 Black–Scholes Model and Option-Implied Volatility
- Appendix Probability Distributions and Statistical Analysis
- References
- Index
5 - Dataset Analytics and Risk Measurement
Published online by Cambridge University Press: 20 October 2016
- Frontmatter
- Dedication
- Contents
- Preface
- Acknowledgments
- 1 Analytical Thinking
- 2 The R Language for Statistical Computing
- 3 Financial Statistics
- 4 Financial Securities
- 5 Dataset Analytics and Risk Measurement
- 6 Time Series Analysis
- 7 The Sharpe Ratio
- 8 Markowitz Mean-Variance Optimization
- 9 Cluster Analysis
- 10 Gauging the Market Sentiment
- 11 Simulating Trading Strategies
- 12 Data Exploration Using Fundamentals
- 13 Prediction Using Fundamentals
- 14 Binomial Model for Options
- 15 Black–Scholes Model and Option-Implied Volatility
- Appendix Probability Distributions and Statistical Analysis
- References
- Index
Summary
When performing Monte Carlo simulation in finance, mixture models are probabilistic models that can be used to represent subpopulations within a population. In order to simulate extreme events which can occur in the various financial markets, the subpopulations can be jumps or crashes in the market. While applying a non-Gaussian distribution is common practice for introducing these jumps, it is also reasonable to use two or more single-variate Gaussian distributions and combine them into a mixture model. We apply it to simulations from the foreign exchange markets.
Generating Prices from Log Returns
Performing financial analytics is now easier than ever before due to the sophistication of open source toolkits such as RStudio and web-available market datasets. When forecasting and predicting future outcomes using such data, measuring the uncertainty and risk is important. We start with the most basic properties of mixture models and then work our way into actual market events.
Whether the log returns are Gaussian or normally distributed (the theoretical assumption), or not really normally distributed (the practical reality), simulating prices from log returns is important. Once we know the distribution of the log returns, simulating realistic prices allows one to go back and forth between simulated and actual market prices without losing much accuracy.
R has such convenient functional programming syntax that it can really save, at times, the analyst a lot of programming. The best trick in the book for quantitative finance is the idiom
Ylogrets = diff(log(Y))
Being able to apply the log() function to the vector and then feed the results into the diff() function is quite powerful. Imagine how unwieldy this is in a spreadsheet by comparison. Let's see: we must find the top and bottom of the row with the prices and create a column with the logs, now another column with the differences of the logs which is one row fewer in length. In any case, whether in a spreadsheet program or R, finding the inverse to the above equation is not quite so obvious! A little algebra will get us there, though.
- Type
- Chapter
- Information
- Financial Analytics with RBuilding a Laptop Laboratory for Data Science, pp. 77 - 91Publisher: Cambridge University PressPrint publication year: 2016