R/Rmetrics Workshop Singapore 2010 Diethelm Würtz Mahendra Mehta David Scott Juri Hinz Rmetrics Association & Finance Online
R/Rmetrics Workshop Singapore 2010
Diethelm WürtzMahendra MehtaDavid ScottJuri Hinz
Rmetrics Association & Finance Online
R/Rmetrics eBook Series
R/Rmetrics eBooks is a series of electronic books and user guides aimedat students and practitioner who use R/Rmetrics to analyze financialmarkets.
A Discussion of Time Series Objects for R in Finance (2009)Diethelm Würtz, Yohan Chalabi, Andrew Ellis
Portfolio Optimization with R/Rmetrics (2010),Diethelm Würtz, William Chen, Yohan Chalabi, Andrew Ellis
Basic R for Finance (2010),Diethelm Würtz, Yohan Chalabi, Longhow Lam, Andrew EllisEarly Bird Edition
Financial Market Data for R/Rmetrics (2010)Diethelm Würtz, Andrew Ellis, Yohan ChalabiEarly Bird Edition
Indian Financial Market Data for R/Rmetrics (2010)Diethelm Würtz, Mahendra Mehta, Andrew Ellis, Yohan Chalabi
Presentations from the R/Rmetrics Singapore Workshop (2010)Diethelm Würtz, Mahendra Mehta, Juri Hinz, David Scott
PRESENTATIONS FROM THE
R/RMETRICS
SINGAPORE WORKSHOP 2010
EDITORS:
DIETHELM WÜRTZ
MAHENDRA MEHTA
JURI HINZ
DAVID SCOTT
RMETRICS ASSOCIATION & FINANCE ONLINE
Series Editors:Prof. Dr. Diethelm WürtzInstitute of Theoretical Physics andCurriculum for Computational ScienceSwiss Federal Institute of TechnologyHönggerberg, HIT G 32.38093 Zurich
Dr. Martin HanfFinance Online GmbHZeltweg 78032 Zurich
Contact Address:Rmetrics AssociationZeltweg 78032 [email protected]
Publisher:Finance Online GmbHSwiss Information TechnologiesZeltweg 78032 Zurich
Authors:Diethelm Würtz, Swiss Federal Institute of Technology ZurichMahendra Mehta, NeuralSoft Technologies MumbaiJuri Hinz, National University of Singapore, SingaporeDavid Scott, University of Auckland, Auckland
ISBN: 978-3-906041-08-7
© 2009, Finance Online GmbH, ZurichPermission is granted to make and distribute verbatim copies of this manual provided thecopyright notice and this permission notice are preserved on all copies.Permission is granted to copy and distribute modified versions of this manual under the con-ditions for verbatim copying, provided that the entire resulting derived work is distributedunder the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another lan-guage, under the above conditions for modified versions, except that this permission noticemay be stated in a translation approved by the Rmetrics Association, Zurich.
Limit of Liability/Disclaimer of Warranty: While the publisher and authors have used theirbest efforts in preparing this book, they make no representations or warranties with respectto the accuracy or completeness of the contents of this book and specifically disclaim anyimplied warranties of merchantability or fitness for a particular purpose. No warranty maybe created or extended by sales representatives or written sales materials. The advice andstrategies contained herein may not be suitable for your situation. You should consult with aprofessional where appropriate. Neither the publisher nor authors shall be liable for any lossof profit or any other commercial damages, including but not limited to special, incidental,consequential, or other damages.
Trademark notice: Product or corporate names may be trademarks or registered trademarks,and are used only for identification and explanation, without intent to infringe.
WELCOME
Welcome to the first R/Rmetrics Singapore Conference on “ComputationalTopics in Finance”. We are very glad that you found the time to come tothe Singapore, and for the many of you traveling from the U.S., Europeand various places in Asia, we hope that your journey was not too arduous.
With the R/Rmetrics Singapore Conference, we want to create a new fo-rum where fund and/or risk managers from banks and insurance firms,decision makers, researchers from industry and academia, and studentscan exchange ideas and engage in stimulating discussions.
The environment for this workshop should be a place a little bit asidefrom the mainstream conference of venues, and we are happy to havefound this at the Risk Management Institute of the National University ofSingapore.
About 40 participants are attending the conference, and the mixture, asplanned, is quite heterogeneous. About half are from academia, and theother half from the software and financial industries, including banks.
Last but not least, we want to thank the organizing committee and oursponsors.
We wish you an interesting conference with many inspiring and stimulat-ing discussions.
Diethelm WürtzSingapore, February 2010
v
CONTENTS
WELCOME V
CONTENTS VII
I Friday Morning 1
1 STEFANO IACUS 2
2 JURI HINZ 40
3 DAVID SCOTT 56
4 MARC PAOLELLA 82
II Friday Afternoon 85
5 VIKRAM KURIYAN 86
6 BERNARD LEE 120
7 KAM FONG CHAN 122
8 ANDREW ELLIS 134
9 ANMOL SETHY 148
10 KARIM CHINE 164
III Saturday Morning 167
11 DEFENG SUN 168
12 YOHAN CHALABI 190
vii
CONTENTS VIII
13 JOEL YU 192
14 LEONG CHEE KIA 202
15 DIETHELM WÜRTZ 204
16 PRATAP SONDHI 214
IV Appendix 231
SPONSORS 232
RMETRICS ASSOCIATION 234
PART I
FRIDAY MORNING
1
CHAPTER 1
STEFANO IACUS
2
The "yuima" package: An R framework for simulation and inference
of stochastic differential equations
Stefano M. Iacuson behalf of Yuima Project Team
Department of Economics, Business and StatisticsUniversità degli Studi di Milano, Italy
Most of the theoretical results in modern finance rely on the assumption that the underlying dynamics of asset prices, currencies exchange rates, interest rates, etc are continuous time stochastic proces-ses driven by stochastic differential equations. Continuous time models are also at the basis of option pricing and option pricing often requires Monte Carlo methods. In turn, the Monte Carlo method re-quires a preliminary good model to simulate whose parameters has to be estimated from historical data. Most ready-to-use tools in computational finance relies on pure discrete time models, like arch, garch, etc. and very few examples of software handling continuous time processes in a general fashion are available also in the R community. There still exists a gap between what is going on in mathematical finance and applied finance. The "yuima" package is intended to help in filling this gap.
The Yuima Project is an open source and collaborative effort of several mathematicians and sta-tisticians aimed at developing the R package named "yuima" for simulation and inference of sto-chastic differential equations. The "yuima" package is an environment that follows the paradigm of methods and classes of the S4 system for the R language.
In the "yuima" package stochastic differential equations can be of very abstract type, e.g. uni or multi-dimensional, driven by Wiener process of fractional Brownian motion with general Hurst parameter, with or without jumps specified as Lévy noise. Lévy processes can be specified via compound Poisson description, by the specification of the Lévy measure or via increments and stable laws.
The "yuima" package is intended to offer the basic infrastructure on which complex models and inference procedures can be built on. In particular, the basic set of functions includes the following: 1) Simulation schemes for all types of stochastic differential equations (Wiener, fBm, Lévy). 2) Different subsampling schemes including random sampling with user specified random times distribution, space discretization, tick times, etc. 3) Automatic asymptotic expansion for the approximation and estimation of functionals of diffusion processes with small noise via Malliavin calculus, useful in option pricing. 4) Efficient quasi-likelihood inference for diffusion processes and diffusion processes with jumps.
All simulation schemes, subsampling and inference are designed to work on both regular or irregular grid times (i.e. regular or irregular time series). In special cases also asynchronous data and sampling schemes can be handled. As proof-of-concept (but fully operational) examples of statistical procedures have been implemented like change point analysis in volatility of stochastic differential equations, asynchronous covariance estimation, divergence test statistics.
The Yuima Project was partly supported by Japan Science and Technology Agency, Basic Research Programs PRESTO, Grants-in-Aid for Scientific Research No. 19340021.
1 / 56
The Yuima Project
Stefano M. Iacus (University of Milan & R Core Team)on behalf of Yuima Core Team
Computational Topics in Finance, 1st R/Rmetrics Workshop, February 19/20, 2010, Singapore
Overview of the Yuima Project
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
2 / 56
The Yuima Project Team
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
3 / 56
A. Brouste (Univ. Le Mans, FR)M. Fukasawa (Osaka Univ. JP)H. Hino (Waseda Univ., Tokyo, JP)S.M. Iacus (Milan Univ., IT)K. Kengo (Tokyo Univ., JP)H. Masuda (Kyushu Univ., JP)Y. Shimitzu (Osaka Univ., JP)M. Uchida (Osaka Univ., JP)N. Yoshida (Tokyo Univ., JP). . .more to come
The yuima package1 is written by people working in mathematical statisticsand finance, who actively publish results in the field, have some knowledge ofR, and have the feeling on “what’s next” in the field.
Aims at filling the gap between theory and practice!1The Yuima Project is funded by the Japan Science Technology (JST) Basic Research Programs PRESTO, Grants-in-Aid for Scientific
Research No. 19340021.
The yuima package goal: fill the gap between theory and practice
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
4 / 56
The Yuima Project aims at implementing, via the yuima package, a veryabstract framework to describe probabilistic and statistical properties ofstochastic processes in a way which is the closest as possible to theirmathematical counterparts but also computationally efficient.
⌅ it is an R package, using S4 classes and methods, where the basic classextends to SDE’s with jumps (simple Poisson, Levy), SDE’s driven byfBM, Markov switching regime processes, HMM, etc.
⌅ separates the data description from the inference tools and simulationschemes
⌅ the design allows for multidimensional, multi-noise processesspecification
⌅ it includes a variety of tools useful in finance, like asymptotic expansionof functionals of stochastic processes via Malliavin calculus
Overview of the yuima package
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
5 / 56
The yuima object
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
6 / 56
The main object is the yuima object which allows to describe the model in amathematically sound way.
Then the data and the sampling structure can be included as well or, just thesampling scheme from which data can be generated according to the model.
The package exposes very few generic functions like simulate, qmle, plot,etc. and some other specific functions for special tasks.
Before looking at the details, let us see an overview of the main object.
What contains a yuima object ?
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
7 / 56
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariatemultivariate
ts, xts, ...
Model
diffusionLevy
fractionalBM
MarkovSwitching HMM
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariatemultivariate
ts, xts, ...
Model
diffusionLevy
fractionalBM
MarkovSwitching HMM
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariatemultivariate
ts, xts, ...
Model
diffusionLevy
fractionalBM
MarkovSwitching HMM
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariatemultivariate
ts, xts, ...
Model
diffusionLevy
fractionalBM
MarkovSwitching HMM
What is possible to do with a yuima
object in hands?
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
12 / 56
Yuima
SimulationExact
Euler-Maruyama
Space discr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
Quasi MLEDiff, Jumps,
fBM
AdaptiveBayesMCMC
Changepoint
Modelselection
Akaike’s
LASSO-typeHypothesesTesting
Optionpricing
Asymptoticexpansion
Monte Carlo
Yuima
SimulationExact
Euler-Maruyama
Space discr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
Quasi MLEDiff, Jumps,
fBM
AdaptiveBayesMCMC
Changepoint
Modelselection
Akaike’s
LASSO-typeHypothesesTesting
Optionpricing
Asymptoticexpansion
Monte Carlo
Yuima
SimulationExact
Euler-Maruyama
Space discr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
Quasi MLEDiff, Jumps,
fBM
AdaptiveBayesMCMC
Changepoint
Modelselection
Akaike’s
LASSO-typeHypothesesTesting
Optionpricing
Asymptoticexpansion
Monte Carlo
Yuima
SimulationExact
Euler-Maruyama
Space discr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
Quasi MLEDiff, Jumps,
fBM
AdaptiveBayesMCMC
Changepoint
Modelselection
Akaike’s
LASSO-typeHypothesesTesting
Optionpricing
Asymptoticexpansion
Monte Carlo
Yuima
SimulationExact
Euler-Maruyama
Space discr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
Quasi MLEDiff, Jumps,
fBM
AdaptiveBayesMCMC
Changepoint
Modelselection
Akaike’s
LASSO-typeHypothesesTesting
Optionpricing
Asymptoticexpansion
Monte Carlo
Yuima
SimulationExact
Euler-Maruyama
Space discr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
Quasi MLEDiff, Jumps,
fBM
AdaptiveBayesMCMC
Changepoint
Modelselection
Akaike’s
LASSO-typeHypothesesTesting
Optionpricing
Asymptoticexpansion
Monte Carlo
How it is supposed to work?
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
19 / 56
The model specification
Overview of the YuimaProject
Overview of the yuimapackage
What contains a yuimaobject ?
What is possible to dowith a yuima object inhands?
How it is supposed towork?
Inference
Change-point Analysis
LASSO estimation
Asymptotic Expansion
Roadmap
20 / 56
We consider here the three main classes of SDE’s which can be easilyspecified. All multidimensional and eventually parametric models.