View
216
Download
2
Category
Preview:
Citation preview
S.M. Iacus 2011 R in Finance 1 / 113
Statistical data analysis of financial time seriesand option pricing in R
S.M. Iacus (University of Milan)
Chicago, R/Finance 2011, April 29th
Explorative Data Analysis
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 2 / 113
Cluster Analysis
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 3 / 113
Cluster analysis is concerned with discovering group structure among nobservations, for example time series.
Such methods are based on the notion of dissimilarity. A dissimilaritymeasure d is a symmetric: d(A,B) = d(B,A), non-negative, and suchthat d(A,A) = 0.
Dissimilarities can, but not necessarily be, a metric, i.e.d(A,C) d(A,B) + d(B,C).
Cluster Analysis
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 4 / 113
A clustering method is an algorithm that works on a n n dissimilaritymatrix by aggregating (or, viceversa, splitting) individuals into groups.
Agglomerative algorithms start from n individuals and, at each step,aggregate two of them or move an individual in a group obtained at someprevious step. Such an algorithm stops when only one group with all the nindividuals is formed.
Divisive methods start from a unique group of all individuals by splittingit, at each step, in subgroups till the case when n singletons are formed.
These methods are mainly intended for exploratory data analysis and eachmethod is influenced by the dissimilarity measure d used.
R offers a variety to clustering algorithm and distances to play with but,up to date, not so much towards clustering of time series.
Real Data from NYSE
S.M. Iacus 2011 R in Finance 5 / 113
Next: time series of daily closing quotes, from 2006-01-03 to 2007-12-31, for thefollowing 20 financial assets:
Microsoft Corporation (MSOFT in the plots) Advanced Micro Devices Inc. (AMD)Dell Inc. (DELL) Intel Corporation (INTEL)Hewlett-Packard Co. (HP) Sony Corp. (SONY)Motorola Inc. (MOTO) Nokia Corp. (NOKIA)Electronic Arts Inc. (EA) LG Display Co., Ltd. (LG)Borland Software Corp. (BORL) Koninklijke Philips Electronics NV (PHILIPS)Symantec Corporation (SYMATEC) JPMorgan Chase & Co (JMP)Merrill Lynch & Co., Inc. (MLINCH) Deutsche Bank AG (DB)Citigroup Inc. (CITI) Bank of America Corporation (BAC)Goldman Sachs Group Inc. (GSACHS) Exxon Mobil Corp. (EXXON)
Quotes come from NYSE/NASDAQ. Source Yahoo.com.
Real Data from NYSE. How to cluster them?
S.M. Iacus 2011 R in Finance 6 / 113
25
35
MSOFT
10
30
AMD
20
26
32
DELL
18
24
INTEL
30
45
HP
405060
SONY
16
22
MOTO
20
35
NOKIA
45
55
EA
2006 2007 2008
15
25
LG
Index
35
BORL
30
40
PHILIPS
15
19
SYMATEC
40
50
JPM
50
80
MLINCH
100
140
DB
30
45
CITI
42
50
BAC
140
220
GSACHS
2006 2007 2008
60
80
EXXON
Index
quotes
How to measure the distance between two time series?
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 7 / 113
The are several ways to measure the distance between two time series
the Euclidean distance dEUC
the Short-Time-Series distance dSTS
the Dynamic Time Warping distance dDTW
the Markov Operator distance dMO
the Euclidean distance dEUC
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 8 / 113
Let X and Y be two time series, then the usual Euclidean distance
dEUC(X,Y ) =
N
i=1
(Xi Yi)2
is one of the most used in the applied literature. We use it only forcomparison purposes.
the Short-Time-Series distance dSTS
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 9 / 113
Let X and Y be two time series, then the usual Euclidean distance
dSTS(X,Y ) =
N
i=1
(
Xi Xi1
Yi Yi1
)2
.
Dynamic Time Warping distance dDTW
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 10 / 113
Let X and Y be two time series, then
dDTW (X,Y ) =
N
i=1
(
Xi Xi1
Yi Yi1
)2
.
DTW allows for non-linear alignments between time series notnecessarily of the same length.
Essentially, all shiftings between two time series are attempted and eachtime a cost function is applied (e.g. a weighted Euclidean distancebetween the shifted series). The minimum of the cost function over allpossible shiftings is the dynamic time warping distance dDTW .
The Markov operator
S.M. Iacus 2011 R in Finance 11 / 113
ConsiderdXt = b(Xt)dt+ (Xt)dWt
therefore, the discretized observations Xi form a Markov process and all the mathematicalproperties are embodied in the so-called transition operator
Pf(x) = E{f(Xi)|Xi1 = x}
with f is a generic function, e.g. f(x) = xk.
Notice that P depends on the transition density between Xi and Xi1, so we putexplicitly the dependence on in the notation.
Luckily, there is no need to deal with the transition density, we can estimate P directlyand easily.
The Markov Operator distance dMO
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 12 / 113
Let X and Y be two time series, then
dMO(X,Y) =
j,kJ
(P)j,k(X) (P)j,k(Y)
, (1)
where (P)j,k() is a matrix and it is calculated as in (2) separately for Xand Y.
(P)j,k(X) =1
2N
N
i=1
{j(Xi1)k(Xi) + k(Xi1)j(Xi)} (2)
The terms (P)j,k are approximations of the scalar product< Pj , k >b, where b and are the unknown drift and diffusioncoefficient of the model. Thus, (P)j,k contains all the information of theMarkovian structure of X .
Simulations
S.M. Iacus 2011 R in Finance 13 / 113
We simulate 10 paths Xi, i = 1, . . . , 10, according to the combinations of drift bi anddiffusion coefficients i, i = 1, . . . , 4 presented in the following table
1(x) 2(x) 3(x) 4(x)
b1(x) X10, X1 X5b2(x) X2,X3 X4b3(x) X6, X7b4(x) X8
where
b1(x) = 1 2x, b2(x) = 1.5(0.9 x), b3(x) = 1.5(0.5 x), b4(x) = 5(0.05 x)
1(x) = 0.5 + 2x(1 x), 2(x) =
0.55x(1 x)
3(x) =
0.1x(1 x), 4(x) =
0.8x(1 x)
The process X9=1-X1, hence it has drift b1(x) and the same quadratic variation of X1and X10.
Trajectories
S.M. Iacus 2011 R in Finance 14 / 113
X1
0.0
0.4
0.8
X2
0.0
0.4
0.8
X3
0.0
0.4
0.8
X4
0.0
0.4
0.8
1 2 3 4 5 6
0.0
0.4
0.8
X5
Time
X6
0.0
0.4
0.8
X7
0.0
0.4
0.8
X8
0.0
0.4
0.8
X9
0.0
0.4
0.8
1 2 3 4 5 6
0.0
0.4
0.8
X10
Time
Simulated diffusions
Dendrograms
S.M. Iacus 2011 R in Finance 15 / 113
Multidimensional scaling
S.M. Iacus 2011 R in Finance 16 / 113
Software
Explorative DataAnalysis
NYSE data
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 17 / 113
The package sde for the R statistical environment is freely available athttp://cran.R-Project.org.
It contains the function MOdist which calculates the Markov Operatordistance and returns a dist object.
data(quotes)
d
Multidimensional scaling. Clustering of NYSE data.
S.M. Iacus 2011 R in Finance 18 / 113
Estimation of Financial Models
Explorative DataAnalysis
Estimation of FinancialModels
Examples
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 19 / 113
Statistical models
S.M. Iacus 2011 R in Finance 20 / 113
We focus on the general approach to statistical inference for the parameter of models inthe wide class of diffusion processes solutions to stochastic differential equations
dXt = b(,Xt)dt+ (,Xt)dWt
with initial condition X0 and the p-dimensional parameter of interest.
Examples
Explorative DataAnalysis
Estimation of FinancialModels
Examples
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 21 / 113
geometric Brownian motion (gBm)
dXt = Xtdt+ XtdWt
Cox-Ingersoll-Ross (CIR)
dXt = (1 + 2Xt)dt+ 3
XtdWt
Chan-Karolyi-Longstaff-Sanders (CKLS)
dXt = (1 + 2Xt)dt+ 3X4t dWt
Examples
Explorative DataAnalysis
Estimation of FinancialModels
Examples
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 22 / 113
nonlinear mean reversion (At-Sahalia)
dXt = (1X1t + 0 + 1Xt + 2X
2t )dt+ 1X
t dWt
double Well potential (bimodal behaviour, highly nonlinear)
dXt = (Xt X3t )dt+ dWt
Jacobi diffusion (political polarization)
dXt = (
Xt 1
2
)
dt+
Xt(1Xt)dWt
Examples
Explorative DataAnalysis
Estimation of FinancialModels
Examples
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 23 / 113
Ornstein-Uhlenbeck (OU)
dXt = Xtdt+ dWt
radial Ornstein-Uhlenbeck
dXt = (X1t Xt)dt+ dWt
hyperbolic diffusion (dynamics of sand)
dXt =2
2
[
Xt2 + (Xt )2
]
dt+ dWt
...and so on.
Likelihood approach
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
MLE
QMLE
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 24 / 113
Likelihood in discrete time
S.M. Iacus 2011 R in Finance 25 / 113
Consider the modeldXt = b(,Xt)dt+ (,Xt)dWt
with initial condition X0 and the p-dimensional parameter of interest. By Markovproperty of diffusion processes, the likelihood has this form
Ln() =n
i=1
p (, Xi|Xi1) p(X0)
and the log-likelihood is
n() = logLn() =n
i=1
log p (, Xi|Xi1) + log(p(X0)) .
Assumption p(X0) irrelevant, hence p(X0) = 1
As usual, in most cases we dont know the conditional distribution p (, Xi|Xi1)
Maximum Likelihood Estimators (MLE)
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
MLE
QMLE
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 26 / 113
If we study the likelihood Ln() as a function of given the n numbers(X1 = x1, . . . , Xn = xn) and we find that this function has a maximum,we can use this maximum value as an estimate of .
In general we define maximum likelihood estimator of , and weabbreviate this with MLE, the following estimator
n = argmax
Ln()
= argmax
Ln(|X1, X2, . . . , Xn)
provided that the maximum exists.
MLE with R
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
MLE
QMLE
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 27 / 113
It is not always the case, that maximum likelihood estimators can beobtained in explicit form.
For what concerns applications to real data, it is important to know thatMLE are optimal in many respect from the statistical point of view,compared to, e.g. estimators obtained via the method of the moments(GMM) which can produce fairly biased estimates of the models.
R offers a prebuilt generic function called mle in the package stats4which can be used to maximize a likelihood.
The mle function actually minimizes the negative log-likelihood () asa function of the parameter where () = logL().
QUASI - MLE
S.M. Iacus 2011 R in Finance 28 / 113
Consider the multidimensional diffusion process
dXt = b(2, Xt)dt+ (1, Xt)dWt
where Wt is an r-dimensional standard Wiener process independent of the initial valueX0 = x0. Quasi-MLE assumes the following approximation of the true log-likelihood formultidimensional diffusions
n(Xn, ) = 1
2
n
i=1
{
log det(i1(1)) +1
n(Xi nbi1(2))
T1i1
(1)(Xi nbi1(2))
}
(3)
where = (1, 2), Xi = Xti Xti1 , i(1) = (1, Xti), bi(2) = b(2, Xti), = 2, A2 = ATA and A1 the inverse of A. Then the QML estimator of is
n = argmin
n(Xn, )
QUASI - MLE
S.M. Iacus 2011 R in Finance 29 / 113
Consider the matrix
(n) =
( 1nn
Ip 0
0 1nIq
)
where Ip and Iq are respectively the identity matrix of order p and q. Then, is possible toshow that
(n)1/2(n )d N(0, I()1).
where I() is the Fisher information matrix.
The above result means that the estimator of the parameter of the drift converges slowly tothe true value because nn = T slower than n, as n .
QUASI - MLE using yuima package
S.M. Iacus 2011 R in Finance 30 / 113
To estimate a model we make use of the qmle function in the yuima package, whoseinterface is similar to mle. Consider the model
dXt = 2Xtdt+ 1dWtwith 1 = 0.3 and 2 = 0.1
R> library(yuima)
R> ymodel n ysamp yuima set.seed(123)R> yuima
QUASI - MLE. True values: 1 = 0.3, 2 = 0.1
S.M. Iacus 2011 R in Finance 31 / 113
We can now try to estimate the parameters
R> mle1 coef(mle1)
theta1 theta20.30766981 0.05007788R> summary(mle1)Maximum likelihood estimation
Coefficients:Estimate Std. Error
theta1 0.30766981 0.02629925theta2 0.05007788 0.15144393
-2 log L: -280.0784
not very good estimate of the drift so now we consider a longer time series.
QUASI - MLE. True values: 1 = 0.3, 2 = 0.1
S.M. Iacus 2011 R in Finance 32 / 113
R> n ysamp yuima set.seed(123)R> yuima mle1 coef(mle1)
theta1 theta20.3015202 0.1029822R> summary(mle1)Maximum likelihood estimation
Coefficients:Estimate Std. Error
theta1 0.3015202 0.006879348theta2 0.1029822 0.114539931
-2 log L: -4192.279
Two stage least squares estimation
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 33 / 113
At-Sahalias interest rates model
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 34 / 113
At-Sahalia in 1996 proposed a model much more sophisticated than theCKLS to include other polynomial terms.
dXt = (1X1t + 0 + 1Xt + 2X
2t )dt+ 1X
t dBt
He proposed to use the two stage least squares approach in the followingmanner.
At-Sahalias interest rates model
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 34 / 113
At-Sahalia in 1996 proposed a model much more sophisticated than theCKLS to include other polynomial terms.
dXt = (1X1t + 0 + 1Xt + 2X
2t )dt+ 1X
t dBt
He proposed to use the two stage least squares approach in the followingmanner. First estimate the drift coefficients with a simple linear regressionlike
E(Xt+1 Xt|Xt) = 1X1t + 0 + (1 1)Xt + 2X2t
At-Sahalias interest rates model
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 34 / 113
At-Sahalia in 1996 proposed a model much more sophisticated than theCKLS to include other polynomial terms.
dXt = (1X1t + 0 + 1Xt + 2X
2t )dt+ 1X
t dBt
He proposed to use the two stage least squares approach in the followingmanner. First estimate the drift coefficients with a simple linear regressionlike
E(Xt+1 Xt|Xt) = 1X1t + 0 + (1 1)Xt + 2X2t
then, regress the residuals 2t+1 from the first regression to obtain theestimates of the coefficients in the diffusion term with
E(2t+1|Xt) = 0 + 1Xt + 2X3t
At-Sahalias interest rates model
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 34 / 113
At-Sahalia in 1996 proposed a model much more sophisticated than theCKLS to include other polynomial terms.
dXt = (1X1t + 0 + 1Xt + 2X
2t )dt+ 1X
t dBt
He proposed to use the two stage least squares approach in the followingmanner. First estimate the drift coefficients with a simple linear regressionlike
E(Xt+1 Xt|Xt) = 1X1t + 0 + (1 1)Xt + 2X2t
then, regress the residuals 2t+1 from the first regression to obtain theestimates of the coefficients in the diffusion term with
E(2t+1|Xt) = 0 + 1Xt + 2X3t
and finally, use the fitted values from the last regression to set the weightsin the second stage regression for the drift.
Example of 2SLS estimation
S.M. Iacus 2011 R in Finance 35 / 113
Stage one: regression
E(Xt+1 Xt|Xt) = 1X1t + 0 + (1 1)Xt + 2X2t
R> library(Ecdat)R> data(Irates)R> X Y stage1 coef(stage1)(Intercept) I(1/Y) Y I(Y^2)0.253478884 -0.135520883 -0.094028341 0.007892979
Example of 2SLS estimation
S.M. Iacus 2011 R in Finance 36 / 113
Stage regression now we extract the squared residuals and run a regression on those
E(2t+1|Xt) = 0 + 1Xt + 2X3t
R> eps2 mod w stage2 coef(stage2)(Intercept) I(1/Y) Y I(Y^2)0.189414678 -0.104711262 -0.073227254 0.006442481R> coef(mod)
b0 b1 b2 b30.00001000 0.09347354 0.00001000 0.00001000
Model selection
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Idea
AIC example
Lasso
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 37 / 113
Idea
S.M. Iacus 2011 R in Finance 38 / 113
The aim is to try to identify the underlying continuous model on the basis of discreteobservations using AIC (Akaike Information Criterion) statistics defined as (Akaike1973,1974)
AIC = 2n(
(ML)n
)
+ 2dim(),
where (ML)n is the true maximum likelihood estimator and n() is the log-likelihood
Model selection via AIC
S.M. Iacus 2011 R in Finance 39 / 113
Akaikes index idea AIC = 2n(
(ML)n
)
+ 2dim() is to penalize this value
2n(
(ML)n
)
with the dimension of the parameter space
2 dim()
Thus, as the number of parameter increases, the fit may be better, i.e. 2n(
(ML)n
)
decreases, at the cost of overspecification and dim() compensate for this effect.
When comparing several models for a given data set, the models such that the AIC islower is preferred.
Model selection via AIC
S.M. Iacus 2011 R in Finance 40 / 113
In order to calculateAIC = 2n
(
(ML)n
)
+ 2dim(),
we need to evaluate the exact value of the log-likelihood n() at point (ML)n .
Problem: for discretely observed diffusion processes the true likelihood function is notknown in most cases
Uchida and Yoshida (2005) develop the AIC statistics defined as
AIC = 2n(
(QML)n
)
+ 2dim(),
where (QML)n is the quasi maximum likelihood estimator and n the local Gaussianapproximation of the true log-likelihood.
A trivial example
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Idea
AIC example
Lasso
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 41 / 113
We compare three models
dXt = 1(Xt 2)dt+ 1
XtdWt (true model),
dXt = 1(Xt 2)dt+
1 + 2XtdWt (competing model 1),
dXt = 1(Xt 2)dt+ (1 + 2Xt)3dWt (competing model 2),
We call the above models Mod1, Mod2 and Mod3.
We generate data from Mod1 with parameters
dXt = (Xt 10)dt+ 2
XtdWt ,
and initial value X0 = 8. We use n = 1000 and = 0.1.
We test the performance of the AIC statistics for the three competingmodels
Simulation results. 1000 Monte Carlo replications
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Idea
AIC example
Lasso
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 42 / 113
dXt = (Xt 10)dt+ 2
XtdWt (true model),
dXt = 1(Xt 2)dt+ 1
XtdWt (Model 1)
dXt = 1(Xt 2)dt+
1 + 2XtdWt (Model 2)
dXt = 1(Xt 2)dt+ (1 + 2Xt)3dWt (Model 3)
Model selection via AICModel 1 Model 2 Model 3
(true)99.2 % 0.6 % 0.2 %
QMLE estimates under the different models1 2 1 2 3
Model 1 1.10 8.05 0.90Model 2 1.12 8.07 2.02 0.54Model 3 1.12 9.03 7.06 7.26 0.61
LASSO estimation
S.M. Iacus 2011 R in Finance 43 / 113
The Least Absolute Shrinkage and Selection Operator (LASSO) is a useful and wellstudied approach to the problem of model selection and its major advantage is thesimultaneous execution of both parameter estimation and variable selection (seeTibshirani, 1996; Knight and Fu, 2000, Efron et al., 2004).To simplify the idea: take a full specified regression model
Y = 0 + 1X1 + 2X2 + + kXk
perform least squares estimation under L1 constraints, i.e.
= argmin
{
(Y X)T (Y X) +k
i=1
|i|}
model selection occurs when some of the i are estimated as zeros.
The SDE model
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Idea
AIC example
Lasso
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 44 / 113
Let Xt be a diffusion process solution to
dXt = b(,Xt)dt+ (,Xt)dWt
= (1, ..., p) p Rp, p 1
= (1, ..., q) q Rq, q 1
b : p Rd Rd, : q Rd Rd Rm and Wt, t [0, T ], is astandard Brownian motion in Rm.
We assume that the functions b and are known up to and .
We denote by = (, ) p q = the parametric vector and with0 = (0, 0) its unknown true value.
Let Hn(Xn, ) = n() from the local Gaussian approximation.
Quasi-likelihood function
S.M. Iacus 2011 R in Finance 45 / 113
The classical adaptive LASSO objective function for the present model is then
min,
Hn(, ) +
p
j=1
n,j |j |+q
k=1
n,k|k|
n,j and n,k are appropriate sequences representing an adaptive amount of shrinkage foreach element of and .
Idea of Quadratic Approximation
S.M. Iacus 2011 R in Finance 46 / 113
By Taylor expansion of the original LASSO objective function, for around n (theQMLE estimator)
Hn(Xn, ) = Hn(Xn, n) + ( n)Hn(Xn, n) +1
2( n)Hn(Xn, n)( n)
+op(1)
= Hn(Xn, n) +1
2( n)Hn(Xn, n)( n) + op(1)
with Hn and Hn the gradient and Hessian of Hn with respect to .
The Adaptive LASSO estimator
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Idea
AIC example
Lasso
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 47 / 113
Finally, the adaptive LASSO estimator is defined as the solution to thequadratic problem under L1 constraints
n = (n, n) = argmin
F().
with
F() = ( n)Hn(Xn, n)( n) +p
j=1
n,j |j |+q
k=1
n,k|k|
The lasso method is implemented in the yuima package.
How to choose the adaptive sequences
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Idea
AIC example
Lasso
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 48 / 113
Clearly, the theoretical and practical implications of our method rely tothe specification of the tuning parameter n,j and n,k.
The tuning parameters should be chosen as is Zou (2006) in the followingway
n,j = 0|n,j|1 , n,k = 0|n,j|2 (4)
where n,j and n,k are the unpenalized QML estimator of j and krespectively, 1, 2 > 0 and usually taken unitary.
Numerical Evidence
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 49 / 113
A multidimensional example
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 50 / 113
We consider this two dimensional geometric Brownian motion processsolution to the stochastic differential equation
(
dXtdYt
)
=
(
1 11Xt + 12Yt2 + 21Xt 22Yt
)
dt+
(
11Xt 12Yt21Xt 22Yt
)(
dWtdBt
)
with initial condition (X0 = 1, Y0 = 1) and Wt, t [0, T ], andBt, t [0, T ], are two independent Brownian motions.
This model is a classical model for pricing of basket options inmathematical finance.
We assume that = (11 = 0.9, 12 = 0, 21 = 0, 22 = 0.7) and = (11 = 0.3, 12 = 0, 21 = 0, 22 = 0.2)
, = (, ).
Results
S.M. Iacus 2011 R in Finance 51 / 113
11 12 21 22 11 12 21 22True 0.9 0.0 0.0 0.7 0.3 0.0 0.0 0.2Qmle: n = 100 0.96 0.05 0.25 0.81 0.30 0.04 0.01 0.20
(0.08) (0.06) (0.27) (0.15) (0.03) (0.05) (0.02) (0.02)
Lasso: 0 = 0 = 1, n = 100 0.86 0.00 0.05 0.71 0.30 0.02 0.01 0.20(0.12) (0.00) (0.13) (0.09) (0.03) (0.05) (0.02) (0.02)
% of times i = 0 0.0 99.9 80.2 0.0 0.3 67.2 66.7 0.1
Lasso: 0 = 0 = 5, n = 100 0.82 0.00 0.00 0.66 0.29 0.01 0.00 0.20(0.12) (0.00) (0.00) (0.09) (0.03) (0.03) (0.01) (0.02)
% of times i = 0 0.0 100.0 99.9 0.0 0.4 86.9 89.7 0.2
Qmle: n = 1000 0.95 0.03 0.21 0.79 0.30 0.04 0.01 0.20(0.07) (0.04) (0.25) (0.13) (0.03) (0.06) (0.02) (0.02)
Lasso: 0 = 0 = 1, n = 1000 0.88 0.00 0.08 0.73 0.30 0.02 0.01 0.20(0.08) (0.00) (0.16) (0.09) (0.03) (0.05) (0.01) (0.02)
% of times i = 0 0.0 99.7 72.1 0.0 0.1 67.5 66.6 0.1
Lasso: 0 = 0 = 5, n = 1000 0.86 0.00 0.00 0.68 0.29 0.01 0.00 0.20(0.09) (0.00) (0.01) (0.06) (0.03) (0.04) (0.01) (0.02)
% of times i = 0 0.0 100.0 99.4 0.0 0.2 87.8 89.9 0.2
Application to real data
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 52 / 113
Interest rates LASSO estimation examples
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 53 / 113
rates
1950 1960 1970 1980 1990
05
10
15
Interest rates LASSO estimation examples
S.M. Iacus 2011 R in Finance 54 / 113
LASSO estimation of the U.S. Interest Rates monthly data from 06/1964 to 12/1989.These data have been analyzed by many author including Nowman (1997), At-Sahalia(1996), Yu and Phillips (2001) and it is a nice application of LASSO.
Reference Model Merton (1973) dXt = dt+ dWt 0 0Vasicek (1977) dXt = (+ Xt)dt+ dWt 0Cox, Ingersoll and Ross (1985) dXt = (+ Xt)dt+
XtdWt 1/2
Dothan (1978) dXt = XtdWt 0 0 1Geometric Brownian Motion dXt = Xtdt+ XtdWt 0 1Brennan and Schwartz (1980) dXt = (+ Xt)dt+ XtdWt 1
Cox, Ingersoll and Ross (1980) dXt = X3/2t dWt 0 0 3/2
Constant Elasticity Variance dXt = Xtdt+ Xt dWt 0
CKLS (1992) dXt = (+ Xt)dt+ Xt dWt
Interest rates LASSO estimation examples
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 55 / 113
Model Estimation Method Vasicek MLE 4.1889 -0.6072 0.8096
CKLS Nowman 2.4272 -0.3277 0.1741 1.3610
CKLS Exact Gaussian 2.0069 -0.3330 0.1741 1.3610(Yu & Phillips) (0.5216) (0.0677)
CKLS QMLE 2.0822 -0.2756 0.1322 1.4392(0.9635) (0.1895) (0.0253) (0.1018)
CKLS QMLE + LASSO 1.5435 -0.1687 0.1306 1.4452with mild penalization (0.6813) (0.1340) (0.0179) (0.0720)
CKLS QMLE + LASSO 0.5412 0.0001 0.1178 1.4944with strong penalization (0.2076) (0.0054) (0.0179) (0.0720)
LASSO selected: Cox, Ingersoll and Ross (1980) model
dXt =1
2dt+ 0.12 X3/2t dWt
Lasso in practice
S.M. Iacus 2011 R in Finance 56 / 113
An example of Lasso estimation using yuima package. We make use of real data withCKLS model
dXt = (+ Xt)dt+ Xt dWt
R> library(Ecdat)R> data(Irates)R> rates plot(rates)R> require(yuima)R> X mod yuima
Example of Lasso estimation
S.M. Iacus 2011 R in Finance 57 / 113
R> lambda10 start low upp lasso10 round(lasso10$mle, 3) # QMLEsigma gamma alpha beta0.133 1.443 2.076 -0.263
R> round(lasso10$lasso, 3) # LASSOsigma gamma alpha beta0.117 1.503 0.591 0.000
dXt = (+ Xt)dt+ Xt dWt
dXt = 0.6dt+ 0.12X3
2
t dWt
The change point problem
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 58 / 113
Change point problem
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 59 / 113
Discover from the data a structural change in the generating model.
Change point problem
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 59 / 113
Discover from the data a structural change in the generating model.Next famous example shows historical change points for the Dow-Jonesindex.
Change point problem
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 59 / 113
Discover from the data a structural change in the generating model.Next famous example shows historical change points for the Dow-Jonesindex.
750
850
950
1050
1972 1973 1974
Dow-Jones closings-0.06
0.00
0.04
1972 1973 1974
Dow-Jones returns
break of gold-US$ linkage (left) Watergate scandal (right)
Least squares approach
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 60 / 113
De Gregorio and I. (2008) considered the change point problem for theergodic model
dXt = b(Xt)dt+(Xt)dWt, 0 t T,X0 = x0,
observed at discrete time instants. The change point problem isformulated as follows
Xt =
{
X0 + t0 b(Xs)ds+
1
t0 (Xs)dWs, 0 t
X + t b(Xs)ds+
2
t (Xs)dWs,
< t T
where (0, T ) is the change point and 1, 2 two parameters to beestimated.
Least squares approach
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 61 / 113
Let Zi =Xi+1 Xi b(Xi)n
n(Xi)be the standardized residuals. Then the
LS estimator of is n = k0/n where k0 is solution to
k0 = argmaxk
k
n Sk
Sn
, Sk =k
i=1
Z2i .
Least squares approach
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 61 / 113
Let Zi =Xi+1 Xi b(Xi)n
n(Xi)be the standardized residuals. Then the
LS estimator of is n = k0/n where k0 is solution to
k0 = argmaxk
k
n Sk
Sn
, Sk =k
i=1
Z2i .
If we assume to observe the following SDE with unknown drift b()
dXt = b(Xt)dt+dWt,
we can still estimate b() non parametrically and obtain a good changepoint estimator.
This approach has been used in Smaldone (2009) to re-analyze the recentglobal financial crisis using data from different markets.
June 30July 4
July 7July 11
July 14July18
August 18August 22
August 25August 29
Sept. 1Sept. 5
Sept. 8Sept. 12
Sept. 15Sept. 19
Sept. 22Sept. 26
Sept. 29Oct. 3
Oct. 6Oct. 10
Oct. 20Oct 24
LehmanBrothers
DJ Stoxx Global 1800 Banks
S&P MIBNikkei 225
FTSEDJ Stoxx 600
LehmanBrothers
DJ Stoxx 600 Banks
GoldmanSachs
Deutsche BankHSBC Nasdaq
Dj Stoxx Asia Pacific 600 BanksJP Morgan Chase
NyseDow JonesS&P 500FTSEDAXS&P MIBCACIBEXSMINikkei 225DJ Stoxx 600 Banks
DJ Stoxx Global 1800MCSI WorldMorgan StanleyBank of AmericaBarclaysRBSUnicreditIntesa SanpaoloDeutsche Bank (GER)Commerzbank
NyseDow JonesS&P 500FTSEDAXS&P MIBCACIBEXSMINikkei 225DJ Stoxx 600 Banks
DJ Stoxx Global 1800MCSI WorldMorgan StanleyBank of AmericaBarclaysRBSUnicreditIntesa SanpaoloDeutsche Bank (GER)Commerzbank
DJ Stoxx America 600 BanksDJ Stoxx 600 BanksDeutsche BankHBSCBarclaysDeutsche Bank (GER)CAC
DJ Stoxx America 600 BanksDJ Stoxx 600 BanksDeutsche BankHBSCBarclaysDeutsche Bank (GER)CAC
Time
cpoint function in the sde package
S.M. Iacus 2011 R in Finance 63 / 113
0 50 100 150 200
0.
04
0.02
0.00
0.02
0.04
log returns
Index
X
16
18
20
22
S [20040723/20050505]
16
18
20
22
Last 20.45Bollinger Bands (20,2) [Upper/Lower]: 21.731/20.100
Lug 232004
Ott 012004
Dic 012004
Feb 012005
Apr 012005
> S require(sde)> cpoint(S)$k0[1] 123$tau0[1] "2005-01-11"$theta12005-01-120.1020001$theta2[1] 0.3770111attr(,"index")[1] "2005-01-12"
Volatility Change-Point Estimation
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 64 / 113
The theory works for SDEs of the form
dYt = btdt+ (Xt, )dWt, t [0, T ],
where Wt a r-dimensional Wiener process and bt and Xt aremultidimensional processes and is the diffusion coefficient (volatility)matrix.
When Y = X the problem is a diffusion model.
The process bt may have jumps but should not explode and it is treated asa nuisance in this model and it is completely unspecified.
Change-point analysis
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 65 / 113
The change-point problem for the volatility is formalized as follows
Yt =
{
Y0 + t0 bsds+
t0 (Xs,
1)dWs for t [0, )
Y + t bsds+
t (Xs,
2)dWs for t [, T ].
The change point instant is unknown and is to be estimated, along with1 and
2, from the observations sampled from the path of (X,Y ).
Example of Volatility Change-Point Estimation
S.M. Iacus 2011 R in Finance 66 / 113
Consider the 2-dimensional stochastic differential equation
(
dX1tdX2t
)
=
(
1X1t3X2t
)
dt+
[
1.1 X1t 0 X1t0 X2t 2.2 X2t
](dW 1tdW 2t
)
X10 = 1.0, X20 = 1.0,
with change point instant at time = 4
x1
0.5
1.5
0 2 4 6 8 10
13
57
x2
the CPoint function in the yuima package
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Least Squares
QMLE
Overview of the yuimapackage
Option Pricing with R
S.M. Iacus 2011 R in Finance 67 / 113
the object yuima contains the model and the data from the previous slideso we can call CPoint on this yuima object
> t.est > t.est$tau[1] 3.99
Overview of the yuima package
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 68 / 113
The yuima object
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 69 / 113
The main object is the yuima object which allows to describe the modelin a mathematically sound way.
Then the data and the sampling structure can be included as well or, justthe sampling scheme from which data can be generated according to themodel.
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.
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariate
multivariatets, xts, ...
Model
diffusionLvy
fractionalBM
MarkovSwitching HMM
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariate
multivariatets, xts, ...
Model
diffusionLvy
fractionalBM
MarkovSwitching HMM
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariate
multivariatets, xts, ...
Model
diffusionLvy
fractionalBM
MarkovSwitching HMM
YuimaSampling
randomdeterministic
tick timesspace disc.
...
regularirregular
multigridasynch.
Dataunivariate
multivariatets, xts, ...
Model
diffusionLvy
fractionalBM
MarkovSwitching HMM
yuima
yuima-class
yuima-class
model
data
sampling
characteristic
functional
data
yuima.data
yuima.data
original.data
zoo.data
model
yuima.model
yuima.model
drift
diffusion
hurst
measure
measure.type
state.variable
parameter
state.variable
jump.variable
time.variable
noise.number
equation.number
dimension
solve.variable
xinit
J.flag
sampling
yuima.sampling
yuima.sampling
Initial
Terminal
n
delta
grid
random
regular
sdelta
sgrid
oindex
interpolation
characteristic
yuima.characteristic
yuima.characteristic
equation.number
time.scale
functional
yuima.functional
yuima.functional
F
f
xinit
e
Yuima
SimulationExact
Euler-Maruyama
Spacediscr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
QuasiMLEDiff,
Jumps,fBM
AdaptiveBayes
MCMCChange
point
Modelselection
Akaikes
LASSO-type
HypothesesTesting
Optionpricing
Asymptoticexpansion
MonteCarlo
Yuima
SimulationExact
Euler-Maruyama
Spacediscr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
QuasiMLEDiff,
Jumps,fBM
AdaptiveBayes
MCMCChange
point
Modelselection
Akaikes
LASSO-type
HypothesesTesting
Optionpricing
Asymptoticexpansion
MonteCarlo
Yuima
SimulationExact
Euler-Maruyama
Spacediscr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
QuasiMLEDiff,
Jumps,fBM
AdaptiveBayes
MCMCChange
point
Modelselection
Akaikes
LASSO-type
HypothesesTesting
Optionpricing
Asymptoticexpansion
MonteCarlo
Yuima
SimulationExact
Euler-Maruyama
Spacediscr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
QuasiMLEDiff,
Jumps,fBM
AdaptiveBayes
MCMCChange
point
Modelselection
Akaikes
LASSO-type
HypothesesTesting
Optionpricing
Asymptoticexpansion
MonteCarlo
Yuima
SimulationExact
Euler-Maruyama
Spacediscr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
QuasiMLEDiff,
Jumps,fBM
AdaptiveBayes
MCMCChange
point
Modelselection
Akaikes
LASSO-type
HypothesesTesting
Optionpricing
Asymptoticexpansion
MonteCarlo
Yuima
SimulationExact
Euler-Maruyama
Spacediscr.
NonparametricsCovariation p-variation
ParametricInference
High freq.Low freq.
QuasiMLEDiff,
Jumps,fBM
AdaptiveBayes
MCMCChange
point
Modelselection
Akaikes
LASSO-type
HypothesesTesting
Optionpricing
Asymptoticexpansion
MonteCarlo
The model specification
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 81 / 113
We consider here the three main classes of SDEs which can be easilyspecified. All multidimensional and eventually parametric models.
The model specification
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 81 / 113
We consider here the three main classes of SDEs which can be easilyspecified. All multidimensional and eventually parametric models.
Diffusions dXt = a(t,Xt)dt+ b(t,Xt)dWt
The model specification
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 81 / 113
We consider here the three main classes of SDEs which can be easilyspecified. All multidimensional and eventually parametric models.
Diffusions dXt = a(t,Xt)dt+ b(t,Xt)dWt
Fractional Gaussian Noise, with H the Hurst parameter
dXt = a(t,Xt)dt+ b(t,Xt)dWHt
The model specification
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 81 / 113
We consider here the three main classes of SDEs which can be easilyspecified. All multidimensional and eventually parametric models.
Diffusions dXt = a(t,Xt)dt+ b(t,Xt)dWt
Fractional Gaussian Noise, with H the Hurst parameter
dXt = a(t,Xt)dt+ b(t,Xt)dWHt
Diffusions with jumps, Lvy
dXt = a(Xt)dt+ b(Xt)dWt +
|z|>1
c(Xt, z)(dt, dz)
+
0
dXt = 3Xtdt+ 11+X2t dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 82 / 113
> mod1
dXt = 3Xtdt+ 11+X2t dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 82 / 113
> mod1
dXt = 3Xtdt+ 11+X2t dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 83 / 113
> mod1 str(mod1)Formal class yuima.model [package "yuima"] with 16 slots
..@ drift : expression((-3 * x))
..@ diffusion :List of 1
.. ..$ : expression(1/(1 + x^2))
..@ hurst : num 0.5
..@ jump.coeff : expression()
..@ measure : list()
..@ measure.type : chr(0)
..@ parameter :Formal class model.parameter [package "yuima"] with 6 slots
.. .. ..@ all : chr(0)
.. .. ..@ common : chr(0)
.. .. ..@ diffusion: chr(0)
.. .. ..@ drift : chr(0)
.. .. ..@ jump : chr(0)
.. .. ..@ measure : chr(0)
..@ state.variable : chr "x"
..@ jump.variable : chr(0)
..@ time.variable : chr "t"
..@ noise.number : num 1
..@ equation.number: int 1
..@ dimension : int [1:6] 0 0 0 0 0 0
..@ solve.variable : chr "x"
..@ xinit : num 0
..@ J.flag : logi FALSE
dXt = 3Xtdt+ 11+X2t dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 84 / 113
And we can easily simulate and plot the model like
> set.seed(123)> X plot(X)
0.0 0.2 0.4 0.6 0.8 1.0
0.
8
0.6
0.
4
0.2
0.0
0.2
t
x
dXt = 3Xtdt+ 11+X2t dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 85 / 113
The simulate function fills the slots data and sampling
> str(X)
dXt = 3Xtdt+ 11+X2t dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 85 / 113
The simulate function fills the slots data and sampling
> str(X)yuima
yuima-class
yuima-class
model
data
sampling
characteristic
functional
data
yuima.data
yuima.data
original.data
zoo.data
model
yuima.model
yuima.model
drift
diffusion
hurst
measure
measure.type
state.variable
parameter
state.variable
jump.variable
time.variable
noise.number
equation.number
dimension
solve.variable
xinit
J.flag
sampling
yuima.sampling
yuima.sampling
Initial
Terminal
n
delta
grid
random
regular
sdelta
sgrid
oindex
interpolation
characteristic
yuima.characteristic
yuima.characteristic
equation.number
time.scale
functional
yuima.functional
yuima.functional
F
f
xinit
e
dXt = 3Xtdt+ 11+X2t dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 86 / 113
The simulate function fills the slots data and sampling
> str(X)
Formal class yuima [package "yuima"] with 5 slots..@ data :Formal class yuima.data [package "yuima"] with 2 slots.. .. ..@ original.data: ts [1:101, 1] 0 -0.217 -0.186 -0.308 -0.27 ..... .. .. ..- attr(*, "dimnames")=List of 2.. .. .. .. ..$ : NULL.. .. .. .. ..$ : chr "Series 1".. .. .. ..- attr(*, "tsp")= num [1:3] 0 1 100.. .. ..@ zoo.data :List of 1.. .. .. ..$ Series 1:zooreg series from 0 to 1
..@ model :Formal class yuima.model [package "yuima"] with 16 slots
(...) output dropped
..@ sampling :Formal class yuima.sampling [package "yuima"] with 11 slots.. .. ..@ Initial : num 0.. .. ..@ Terminal : num 1.. .. ..@ n : num 100.. .. ..@ delta : num 0.1.. .. ..@ grid : num(0).. .. ..@ random : logi FALSE.. .. ..@ regular : logi TRUE.. .. ..@ sdelta : num(0).. .. ..@ sgrid : num(0).. .. ..@ oindex : num(0).. .. ..@ interpolation: chr "none"
Parametric model: dXt = Xtdt+ 11+Xt dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 87 / 113
> mod2 str(mod2)Formal class yuima.model [package "yuima"] with 16 slots
..@ drift : expression((-theta * x))
..@ diffusion :List of 1
.. ..$ : expression(1/(1 + x^gamma))
..@ hurst : num 0.5
..@ jump.coeff : expression()
..@ measure : list()
..@ measure.type : chr(0)
..@ parameter :Formal class model.parameter [package "yuima"] with 6 slots
.. .. ..@ all : chr [1:2] "theta" "gamma"
.. .. ..@ common : chr(0)
.. .. ..@ diffusion: chr "gamma"
.. .. ..@ drift : chr "theta"
.. .. ..@ jump : chr(0)
.. .. ..@ measure : chr(0)
..@ state.variable : chr "x"
..@ jump.variable : chr(0)
..@ time.variable : chr "t"
..@ noise.number : num 1
..@ equation.number: int 1
..@ dimension : int [1:6] 2 0 1 1 0 0
..@ solve.variable : chr "x"
..@ xinit : num 0
..@ J.flag : logi FALSE
Parametric model: dXt = Xtdt+ 11+Xt dWt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 88 / 113
And this can be simulated specifying the parameters
> simulate(mod2,true.param=list(theta=1,gamma=3))
2-dimensional diffusions with 3 noises
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 89 / 113
dX1t = 3X1t dt+ dW 1t +X2t dW 3tdX2t = (X1t + 2X2t )dt+X1t dW 1t + 3dW 2t
has to be organized into matrix form
(
dX1tdX2t
)
=
(
3X1tX1t 2X2t
)
dt+
(
1 0 X2tX1t 3 0
)
dW 1tdW 2tdW 3t
> sol a b mod3
2-dimensional diffusions with 3 noises
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 90 / 113
dX1t = 3X1t dt+ dW 1t +X2t dW 3tdX2t = (X1t + 2X2t )dt+X1t dW 1t + 3dW 2t
> str(mod3)Formal class yuima.model [package "yuima"] with 16 slots
..@ drift : expression((-3 * x1), (-x1 - 2 * x2))
..@ diffusion :List of 2
.. ..$ : expression(1, 0, x2)
.. ..$ : expression(x1, 3, 0)
..@ hurst : num 0.5
..@ jump.coeff : expression()
..@ measure : list()
..@ measure.type : chr(0)
..@ parameter :Formal class model.parameter [package "yuima"] with 6 slots
.. .. ..@ all : chr(0)
.. .. ..@ common : chr(0)
.. .. ..@ diffusion: chr(0)
.. .. ..@ drift : chr(0)
.. .. ..@ jump : chr(0)
.. .. ..@ measure : chr(0)
..@ state.variable : chr "x"
..@ jump.variable : chr(0)
..@ time.variable : chr "t"
..@ noise.number : int 3
..@ equation.number: int 2
..@ dimension : int [1:6] 0 0 0 0 0 0
..@ solve.variable : chr [1:2] "x1" "x2"
..@ xinit : num [1:2] 0 0
..@ J.flag : logi FALSE
Plot methods inherited by zoo
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 91 / 113
> set.seed(123)> X plot(X,plot.type="single",col=c("red","blue"))
0.0 0.2 0.4 0.6 0.8 1.0
3
2
1
01
t
x1
Multidimensional SDE
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 92 / 113
Also models likes this can be specified
dX1t = X2t
X1t
2/3dW 1t ,
dX2t = g(t)dX3t ,
dX3t = X3t (dt+ (dW
1t +
1 2dW 2t )),
where g(t) = 0.4 + (0.1 + 0.2t)e2t
The above is an example of parametric SDE with more equations thannoises.
Fractional Gaussian Noise dYt = 3Ytdt+ dWHt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 93 / 113
> mod4
Fractional Gaussian Noise dYt = 3Ytdt+ dWHt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 93 / 113
> mod4 str(mod4)Formal class yuima.model [package "yuima"] with 16 slots
..@ drift : expression((3 * y))
..@ diffusion :List of 1
.. ..$ : expression(1)
..@ hurst : num 0.3
..@ jump.coeff : expression()
..@ measure : list()
..@ measure.type : chr(0)
..@ parameter :Formal class model.parameter [package "yuima"] with 6 slots
.. .. ..@ all : chr(0)
.. .. ..@ common : chr(0)
.. .. ..@ diffusion: chr(0)
.. .. ..@ drift : chr(0)
.. .. ..@ jump : chr(0)
.. .. ..@ measure : chr(0)
..@ state.variable : chr "x"
..@ jump.variable : chr(0)
..@ time.variable : chr "t"
..@ noise.number : num 1
..@ equation.number: int 1
..@ dimension : int [1:6] 0 0 0 0 0 0
..@ solve.variable : chr "y"
..@ xinit : num 0
..@ J.flag : logi FALSE
Fractional Gaussian Noise dYt = 3Ytdt+ dWHt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 94 / 113
> set.seed(123)> X plot(X, main="Im fractional!")
0.0 0.2 0.4 0.6 0.8 1.0
01
23
4
t
y
Im fractional!
Jump processes
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 95 / 113
Jump processes can be specified in different ways in mathematics (andhence in yuima package).
Let Zt be a Compound Poisson Process (i.e. jumps follow somedistribution, e.g. Gaussian)
Then is is possible to consider the following SDE which involves jumps
dXt = a(Xt)dt+ b(Xt)dWt + dZt
Next is an example of Poisson process with intensity = 10 andGaussian jumps.
In this case we specify measure.type as CP (Compound Poisson)
Jump process: dXt = Xtdt+ dWt + Zt
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 96 / 113
> mod5 set.seed(123)> X plot(X, main="Im jumping!")
0.0 0.2 0.4 0.6 0.8 1.0
8
6
4
2
0
t
x
Im jumping!
Jump processes
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 97 / 113
Another way is to specify the Lvy measure. Without going into too muchdetails, here is an example of a simple OU process with IG Lvy measuredXt = Xtdt+ dZt
> mod6 set.seed(123)> plot( simulate(mod6, Terminal=10, n=10000), main="Im also jumping!")
0 2 4 6 8 10
05
1015
20
t
x
Im also jumping!
The setModel method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 98 / 113
Models are specified viasetModel(drift, diffusion, hurst = 0.5, jump.coeff, measure,
measure.type, state.variable = x, jump.variable = z, time.variable
= t, solve.variable, xinit) in
dXt = a(Xt)dt+ b(Xt)dWt + c(Xt)dZt
The package implements many multivariate RNG to simulate Lvy pathsincluding rIG, rNIG, rbgamma, rngamma, rstable.
Other user-defined or packages-defined RNG can be used freely.
The setModel method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 99 / 113
Models are specified viasetModel(drift, diffusion, hurst = 0.5, jump.coeff, measure,
measure.type, state.variable = x, jump.variable = z, time.variable
= t, solve.variable, xinit) in
dXt = a(Xt)dt+ b(Xt)dWt + c(Xt)dZt
The package implements many multivariate RNG to simulate Lvy pathsincluding rIG, rNIG, rbgamma, rngamma, rstable.
Other user-defined or packages-defined RNG can be used freely.
The setModel method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 100 / 113
Models are specified viasetModel(drift, diffusion, hurst = 0.5, jump.coeff, measure,
measure.type, state.variable = x, jump.variable = z, time.variable
= t, solve.variable, xinit) in
dXt = a(Xt)dt+ b(Xt)dWt + c(Xt)dZt
The package implements many multivariate RNG to simulate Lvy pathsincluding rIG, rNIG, rbgamma, rngamma, rstable.
Other user-defined or packages-defined RNG can be used freely.
The setModel method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 101 / 113
Models are specified viasetModel(drift, diffusion, hurst = 0.5, jump.coeff, measure,
measure.type, state.variable = x, jump.variable = z, time.variable
= t, solve.variable, xinit) in
dXt = a(Xt)dt+ b(Xt)dWt + c(Xt)dZt
The package implements many multivariate RNG to simulate Lvy pathsincluding rIG, rNIG, rbgamma, rngamma, rstable.
Other user-defined or packages-defined RNG can be used freely.
The setModel method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
yuima object
functionalities
how to use it
Option Pricing with R
S.M. Iacus 2011 R in Finance 102 / 113
Models are specified viasetModel(drift, diffusion, hurst = 0.5, jump.coeff, measure,
measure.type, state.variable = x, jump.variable = z, time.variable
= t, solve.variable, xinit) in
dXt = a(Xt)dt+ b(Xt)dWt + c(Xt)dZt
The package implements many multivariate RNG to simulate Lvy pathsincluding rIG, rNIG, rbgamma, rngamma, rstable.Other user-defined or packages-defined RNG can be used freely.
Option Pricing with R
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 103 / 113
R options for option pricing
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 104 / 113
There are several good packages on CRAN which implement the basicoption pricing formulas. Just to mention a couple (with apologizes to theauthors pf the other packages)
Rmetrics suite which includes: fOptions, fAsianOptions,fExoticOptions
RQuanLib for European, American and Asian option pricing
But if you need to go outside the standard Black & Scholes geometricBrownian Motion model, the only way reamins Monte Carlo analysis.And for jump processes, maybe, yuima package is one of the currentframeworks you an think to use.
In addition, yuima also offers asymptotic expansion formulas for generaldiffusion processes which can be used in Asian option pricing.
Asymptotic expansion
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 105 / 113
The yuima package can handle asymptotic expansion of functionals ofd-dimensional diffusion process
dXt = a(Xt , )dt+ b(X
t , )dWt, (0, 1]
with Wt and r-dimensional Wiener process, i.e. Wt = (W 1t , . . . ,Wrt ).
The functional is expressed in the following abstract form
F (Xt ) =
r
=0
T
0f(X
t , d)dW
t + F (X
t , ), W
0t = t
Estimation of functionals. Example.
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 106 / 113
Example: B&S asian call option
dXt = Xt dt+ X
t dWt
and the B&S price is related to E
{
max
(
1
T
T
0Xt dtK, 0
)}
. Thus
the functional of interest is
F (Xt ) =1
T
T
0Xt dt, r = 1
Estimation of functionals. Example.
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 106 / 113
Example: B&S asian call option
dXt = Xt dt+ X
t dWt
and the B&S price is related to E
{
max
(
1
T
T
0Xt dtK, 0
)}
. Thus
the functional of interest is
F (Xt ) =1
T
T
0Xt dt, r = 1
withf0(x, ) =
x
T, f1(x, ) = 0, F (x, ) = 0
in
F (Xt ) =r
=0
T
0f(X
t , d)dW
t + F (X
t , )
Estimation of functionals. Example.
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 107 / 113
So, the call option price requires the composition of a smooth functional
F (Xt ) =1
T
T
0Xt dt, r = 1
with the irregular function
max(xK, 0)
Monte Carlo methods require a HUGE number of simulations to get thedesired accuracy of the calculation of the price, while asymptoticexpansion of F provides unexpectedly accurate approximations.
The yuima package provides functions to construct the functional F ,and automatic asymptotic expansion based on Malliavin calculus startingfrom a yuima object.
setFunctional method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 108 / 113
> diff.matrix model T xinit f F e yuima yuima
setFunctional method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 108 / 113
> diff.matrix model T xinit f F e yuima yuima
setFunctional method
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 109 / 113
> diff.matrix model T xinit f F e yuima yuima str(yuima)Formal class yuima [package "yuima"] with 5 slots
..@ data :Formal class yuima.data [package "yuima"] with 2 slots
..@ model :Formal class yuima.model [package "yuima"] with 16 slots
..@ sampling :Formal class yuima.sampling [package "yuima"] with 11 slots
..@ functional :Formal class yuima.functional [package "yuima"] with 4 slots
.. .. ..@ F : num 0
.. .. ..@ f :List of 2
.. .. .. ..$ : expression(x/T)
.. .. .. ..$ : expression(0)
.. .. ..@ xinit: num 1
.. .. ..@ e : num 0.3
Estimation of functionals. Example.
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 110 / 113
Then, it is as easy as> F0 F0[1] 1.716424> max(F0-K,0) # asian call option price[1] 0.7164237
Estimation of functionals. Example.
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 110 / 113
Then, it is as easy as> F0 F0[1] 1.716424> max(F0-K,0) # asian call option price[1] 0.7164237
and back to asymptotic expansion, the following script may work> rho get_ge
Add more terms to the expansion
S.M. Iacus 2011 R in Finance 111 / 113
The expansion of previous functional gives> asymp asymp$d0 + e * asymp$d1 # asymp. exp. of asian call price
[1] 0.7148786
> library(fExoticOptions) # From RMetrics suite> TurnbullWakemanAsianApproxOption("c", S = 1, SA = 1, X = 1,+ Time = 1, time = 1, tau = 0.0, r = 0, b = 1, sigma = e)Option Price:
[1] 0.7184944
> LevyAsianApproxOption("c", S = 1, SA = 1, X = 1,+ Time = 1, time = 1, r = 0, b = 1, sigma = e)Option Price:
[1] 0.7184944
> X mean(colMeans((X-K)*(X-K>0))) # MC asian call price based on M=1000 repl.
[1] 0.707046
Multivariate Asymptotic Expansion
Explorative DataAnalysis
Estimation of FinancialModels
Likelihood approach
Two stage least squaresestimation
Model selection
Numerical Evidence
Application to real data
The change pointproblem
Overview of the yuimapackage
Option Pricing with R
Advertizing
S.M. Iacus 2011 R in Finance 112 / 113
Asymptotic expansion is now also available for multidimensionaldiffusion processes like the Heston model
dX1,t = aX1,t dt+ X
1,t
X2,t dW1t
dX2,t = c(dX2,t )dt+
X2,t
(
dW 1t +
1 2dW 2t)
i.e. functionals of the form F (X1,, X2,).
Advertizing
S.M. Iacus 2011 R in Finance 113 / 113
Iacus (2008) Simulation and Inference for Stochastic Differential Equations with RExamples, Springer, New York.
Iacus (2011) Option Pricing and Estimation of Financial Models with R, Wiley &Sons, Chichester.
Explorative Data AnalysisCluster AnalysisCluster AnalysisReal Data from NYSEReal Data from NYSE. How to cluster them?How to measure the distance between two time series?the Euclidean distance dEUCthe Short-Time-Series distance dSTSDynamic Time Warping distance dDTWThe Markov operatorThe Markov Operator distance dMOSimulationsTrajectoriesDendrogramsMultidimensional scalingSoftwareMultidimensional scaling. Clustering of NYSE data.
Estimation of Financial ModelsStatistical modelsExamplesExamplesExamples
Likelihood approachLikelihood in discrete timeMaximum Likelihood Estimators (MLE)MLE with RQUASI - MLEQUASI - MLEQUASI - MLE using yuima packageQUASI - MLE. True values: 1=0.3, 2=0.1QUASI - MLE. True values: 1=0.3, 2=0.1
Two stage least squares estimationAt-Sahalia's interest rates modelExample of 2SLS estimationExample of 2SLS estimation
Model selectionIdeaModel selection via AICModel selection via AICA trivial exampleSimulation results. 1000 Monte Carlo replicationsLASSO estimationThe SDE modelQuasi-likelihood functionIdea of Quadratic ApproximationThe Adaptive LASSO estimatorHow to choose the adaptive sequences
Numerical EvidenceA multidimensional exampleResults
Application to real dataInterest rates LASSO estimation examplesInterest rates LASSO estimation examplesInterest rates LASSO estimation examplesLasso in practiceExample of Lasso estimation
The change point problemChange point problemLeast squares approachLeast squares approachFinancial crisis 2008cpoint function in the sde packageVolatility Change-Point EstimationChange-point analysisExample of Volatility Change-Point Estimationthe CPoint function in the yuima package
Overview of the yuima packageThe yuima objectNice pictNice pictNice pictNice pictThe yuima object: overviewNice pictNice pictNice pictNice pictNice pictNice pictThe model specificationdXt = -3 Xt dt + 11+Xt2dWtdXt = -3 Xt dt + 11+Xt2dWtdXt = -3 Xt dt + 11+Xt2dWtdXt = -3 Xt dt + 11+Xt2dWtdXt = -3 Xt dt + 11+Xt2dWtParametric model: dXt = -Xt dt + 11+XtdWtParametric model: dXt = -Xt dt + 11+XtdWt2-dimensional diffusions with 3 noises2-dimensional diffusions with 3 noisesPlot methods inherited by zooMultidimensional SDEFractional Gaussian Noise dYt = 3 Yt dt + dWtHFractional Gaussian Noise dYt = 3 Yt dt + dWtHJump processesJump process: dXt = -Xt dt + dWt + ZtJump processesThe setModel methodThe setModel methodThe setModel methodThe setModel methodThe setModel method
Option Pricing with RR options for option pricingAsymptotic expansionEstimation of functionals. Example.Estimation of functionals. Example.setFunctional methodsetFunctional methodEstimation of functionals. Example.Add more terms to the expansionMultivariate Asymptotic ExpansionAdvertizing
Recommended