7. List of Examples
1.1 Example (Stochastic discount factor (SDF) for a CAPM) . . . . . . . . . . . . 38
1.2 Example (Short interest rates) . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.1 Example (DEXUSEU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.2 Example (Model selection for a stock price with jumps) . . . . . . . . . . . . . 44
2.3 Example (LASSO for US monthly interest rates) . . . . . . . . . . . . . . . . . 48
2.4 Example (Change point for APPL) . . . . . . . . . . . . . . . . . . . . . . . . 49
2.5 Example (Volatility change-point estimator on DWJ returns) . . . . . . . . . . 51
2.6 Example (Fit VIX to a Carma(2,1) process) . . . . . . . . . . . . . . . . . . . 53
2.7 Example (GARCH model for NXT.L) . . . . . . . . . . . . . . . . . . . . . . . 58
B.1 Example (Novartis log returns) . . . . . . . . . . . . . . . . . . . . . . . . . . 97
B.2 Example (Fitting a multivariate NIG distribution to three swiss blue chips) . . 98
B.3 Example (Fit the daily log-returns of the SMI to the hyperbolic distribution) . 99
0.1 Simulations with yuima
Simulation 0.1: Normal jump size.
yuima::simulate the process
set.seed(123)
mu <- 0
sigma <- 1
lambda <- 10
samp <- setSampling(Terminal=10, n=1000)
mod10 <- setPoisson(intensity="lambda", df=list("dnorm(z,mu,sigma)"))
y10 <- yuima::simulate(mod10,sampling=samp,
true.par=list(lambda=lambda,mu=0.1, sigma=2))
6
8. LIST OF EXAMPLES 7
0 2 4 6 8 10
−10−50510
Figure 1: y10
Simulation 0.2: Bilateral gamma process.
yuima::simulate the process
BGmodel <- setModel(drift="0", xinit="0", jump.coeff="1",
measure.type="code", measure=list(df="rbgamma(z, delta.minus=2,
gamma.minus=0.6, delta.plus=1.4, gamma.plus=0.3)"))
n <- 1000
samp <- setSampling(Terminal=1, n=n)
BGyuima <- setYuima(model=BGmodel, sampling=samp)
9. LIST OF EXAMPLES 8
0.0 0.2 0.4 0.6 0.8 1.0
−6−4−20246
x
0.0 0.2 0.4 0.6 0.8 1.0
−6−4−20246
x
0.0 0.2 0.4 0.6 0.8 1.0
−6−4−20246
x
0.0 0.2 0.4 0.6 0.8 1.0
−6−4−20246
x
Figure 2: Paths of bilateral gamma process
Simulation 0.3: Variance gamma process.
yuima::simulate the process
VGmodel <- setModel(drift="0", xinit="0", jump.coeff="1",
measure.type="code", measure=list(df="rbgamma(z, delta.minus=2,
gamma.minus=0.6, delta.plus=2, gamma.plus=0.3)"))
VGyuima <- setYuima(model=VGmodel, sampling=samp)
0.0 0.2 0.4 0.6 0.8 1.0
0510
x
0.0 0.2 0.4 0.6 0.8 1.0
0510
x
0.0 0.2 0.4 0.6 0.8 1.0
0510
x
0.0 0.2 0.4 0.6 0.8 1.0
0510
x
0.0 0.2 0.4 0.6 0.8 1.0
0510
x
Figure 3: Paths of variance gamma process
10. LIST OF EXAMPLES 9
Simulation 0.4: gamma process.
yuima::simulate the process
Gmodel <- setModel(drift="0", xinit="0", jump.coeff="1",
measure.type="code", measure=list(df="rgamma(z,
shape=0.7, scale=1)"))
n <- 10000
samp <- setSampling(Terminal=1, n=n)
Gyuima <- setYuima(model=Gmodel, sampling=samp)
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.01.2
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.01.2
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.01.2
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.01.2
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.01.2
x
Figure 4: Paths of gamma process
Simulation 0.5: gamma process.
yuima::simulate the process
11. LIST OF EXAMPLES 10
Density
0.0 0.5 1.0 1.5 2.0
0.00.51.01.52.02.53.0
Figure 5: Distribution of x1 and density of Γ(0.7, 1).
Simulation 0.6: inverse gamma process.
yuima::simulate the process
delta <- 1
gamma <- 2
set.seed(127)
x <- rIG(10^4,delta,gamma)
mean(x)
## [1] 0.498
var(x)
## [1] 0.128
12. LIST OF EXAMPLES 11
Density
0.0 0.5 1.0 1.5 2.0
0.00.51.01.52.0
Figure 6: Distribution of x1 and density of IG(1, 2).
Simulation 0.7: inverse gamma process.
yuima::simulate the process
IGmodel <- setModel(drift=0, xinit=0, jump.coeff=1,
measure.type="code", measure=list(df="rIG(z, delta=1, gamma=2)"))
n <- 1000
samp <- setSampling(Terminal=1, n=n)
IGyuima <- setYuima(model=IGmodel, sampling=samp)
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.0
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.0
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.0
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.0
x
0.0 0.2 0.4 0.6 0.8 1.0
0.00.20.40.60.81.0
x
Figure 7: Paths of IG process (delta=1, gamma=2).
13. LIST OF EXAMPLES 12
Simulation 0.8: inverse gamma process.
yuima::simulate the process
Distribution of X1 and Density of IG(1,2)
Density
0.0 0.5 1.0 1.5 2.0
0.00.51.01.52.0
Figure 8: Distribution of x1 and density of IG(1, 2).
Simulation 0.9: process.
yuima::simulate the process
rep <- 3000000
set.seed(129)
X1 <- rpts(rep,0.5,0.2,1)
hist(X1,xlim=c(0,3),ylim=c(0,3),breaks=100,
main=expression(X[1]),probability=TRUE)
14. LIST OF EXAMPLES 13
X1
X1
Density
0.0 0.5 1.0 1.5 2.0 2.5 3.0
0.00.51.01.52.02.53.0
X05 <- rpts(rep,0.5,0.1,1)
X05.prime <- rpts(rep,0.5,0.1,1)
Xsum <- X05+X05.prime
summary(X1)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.01 0.11 0.21 0.35 0.43 11.72
summary(Xsum)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.01 0.11 0.21 0.35 0.43 10.61
ks.test(X1,Xsum)
15. LIST OF EXAMPLES 14
##
## Two-sample Kolmogorov-Smirnov test
##
## data: X1 and Xsum
## D = 8e-04, p-value = 0.3
## alternative hypothesis: two-sided
rm(X1)
rm(Xsum)
rm(X05)
rm(X05.prime)
Simulation 0.10: vgamma process.
yuima::simulate the process
lambda <- 2
alpha <- 1.5
beta <- -0.7
mu <- 3
xinit <- 0
gamma <- sqrt(alpha^2-beta^2)
n <- 1000
T <- 1.8
VGPmodel <- setModel(drift=0, jump.coeff=1, measure.type="code",
measure=list(df="rvgamma(z,lambda,alpha,beta,mu)"))
samp <- setSampling(Terminal=T, n=n)
VGPyuima <- setYuima(model=VGPmodel, sampling=samp)
0.0 0.5 1.0 1.5
−4−20246
x
0.0 0.5 1.0 1.5
−4−20246
x
0.0 0.5 1.0 1.5
−4−20246
x
0.0 0.5 1.0 1.5
−4−20246
x
0.0 0.5 1.0 1.5
−4−20246
x
0.0 0.5 1.0 1.5
−4−20246
x
0.0 0.5 1.0 1.5
−4−20246
x
Figure 9: Paths of variance gamma process.
16. LIST OF EXAMPLES 15
n <- 5
samp <- setSampling(Terminal=T, n=n)
VGPyuima <- setYuima(model=VGPmodel, sampling=samp)
VGPsimdata <- NULL
for (i in 1:5000){
result <- yuima::simulate(VGPyuima, xinit=xinit,
true.par=list(lambda=lambda,alpha=alpha,beta=beta,mu=mu))
x1 <- result@data@original.data[n+1,1]
VGPsimdata <- c(VGPsimdata,as.numeric(x1[1]))
}
Density
−5 0 5 10
0.000.050.100.150.20
Figure 10: Distribution of x1 and density of NG.
Simulation 0.11: subordination process.
yuima::simulate the process
delta <- 0.5
alpha <- 1.5
beta <- -0.7
mu <- 3
gamma <- sqrt(alpha^2-beta^2)
n <- 10000
T <- 1.8
set.seed(127)
normal.rn <- rnorm(n,0,1)
iv.rn <- rIG(n,delta*T,gamma)
z <- mu*T+beta*iv.rn+sqrt(iv.rn)*normal.rn
title <- expression(paste(NIG[1.8],
" built by subordination (green) and rNIG (white)"))
17. LIST OF EXAMPLES 16
nig.rn <- rNIG(n,alpha,beta,delta*T,mu*T)
hist(z,xlim=c(-1,10),ylim=c(0,0.61),breaks=100, freq=FALSE,
col="green", main=title, xlab=expression(X[1.8]) )
curve(dNIG(x,alpha,beta,delta*T,mu*T),add=TRUE,col="red")
par(new=T)
hist(nig.rn,xlim=c(-1,10),ylim=c(0,0.61),breaks=100,
freq=FALSE, main="", xlab="")
NIG1.8 built by subordination (green) and rNIG (white)
X1.8
Density
0 2 4 6 8 10
0.00.10.20.30.40.50.6
Density
0 2 4 6 8 10
0.00.10.20.30.40.50.6
## delta1 <- 0.5
## alpha <- 1.5
## beta <- -0.7
## mu <- 3
18. LIST OF EXAMPLES 17
## xinit <- 0
## gamma <- sqrt(alpha^2-beta^2)
## n <- 1000
## T <- 1.8
## NIG2model <- setModel(drift=0, jump.coeff=1, measure.type="code",
## measure=list(df="rNIG(z,alpha,beta,delta1,mu)"))
## samp <- setSampling(Terminal=T, n=n)
## NIG2yuima <- setYuima(model=NIG2model, sampling=samp)
## set.seed(127)
## for (i in 1:10) {
## result <- yuima::simulate(NIG2yuima, xinit=xinit,
## true.par=list(delta1=delta1, alpha=alpha, beta=beta,
## mu=mu, gamma=gamma))
## plot(result,xlim=c(0,T),ylim=c(-1,10),col=i,
## main="Paths of NIG process",par(new=T))
## }
Simulation 0.12: inverse gamma process.
yuima::simulate the process
19. LIST OF EXAMPLES 18
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
0.0 0.5 1.0 1.5
0246810
t
x
Paths of NIG process
Simulation 0.13: inverse gamma process.
yuima::simulate the process
n <- 5
samp <- setSampling(Terminal=T, n=n)
NIG2yuima <- setYuima(model=NIG2model, sampling=samp)
NIG2data <- NULL
for (i in 1:3000){
result <- yuima::simulate(NIG2yuima, xinit=xinit,
true.par=list(delta1=delta1, alpha=alpha, beta=beta,
mu=mu, gamma=gamma))
x1 <- result@data@original.data[n+1,1]
NIG2data <- c(NIG2data,as.numeric(x1[1]))
20. LIST OF EXAMPLES 19
}
hist(NIG2data,xlim=c(2,8),ylim=c(0,0.8),breaks=100, freq=FALSE,
main=expression(paste("Distribution of ",X[1.8],
" and Density of NIG")))
curve(dNIG(x,alpha,beta,delta*T,mu*T),add=TRUE,col="red")
Distribution of X1.8 and Density of NIG
NIG2data
Density
2 3 4 5 6 7 8
0.00.20.40.60.8
Simulation 0.14: inverse gamma process.
yuima::simulate the process
nrep <- 10^4
alpha <- 0.5
delta <- 0.2
21. LIST OF EXAMPLES 20
gamma <- 1
beta <- 1
mu <- -0.7
Lambda <- matrix(1,1,1)
t <- 1.5
set.seed(127)
x <- rnts(nrep,alpha,delta*t,gamma,beta,mu*t,Lambda)
s <- rpts(nrep,alpha,delta*t,gamma)
w <- rnorm(nrep,0,1)
y <- rep(mu*t,nrep) + beta*s + sqrt(s)*w
opar<-par(mfrow=c(2,2))
hist(x,xlim=c(-3,3),ylim=c(0,1.2),breaks=200,
main=expression(X[t]),probability=TRUE)
hist(y,xlim=c(-3,3),ylim=c(0,1.2),breaks=200,
main=expression(Y[t]),probability=TRUE,col="red")
22. LIST OF EXAMPLES 21
Xt
x
Density
−3 −2 −1 0 1 2 3
0.00.40.81.2 Yt
y
Density
−3 −2 −1 0 1 2 3
0.00.40.81.2
Experiment by convolution
nrep <- 3*10^4
X1 <- rnts(nrep,alpha,delta*t,gamma,beta,mu*t,Lambda)
X05 <- rnts(nrep,alpha,delta*t/2,gamma,beta,mu*t/2,Lambda)
X05.prime <- rnts(nrep,alpha,delta*t/2,gamma,beta,mu*t/2,Lambda)
Xsum <- X05+X05.prime
hist(X1,xlim=c(-3,3),ylim=c(0,1.2),breaks=300,
main=expression(X[1]),probability=TRUE)
23. LIST OF EXAMPLES 22
X1
X1
Density
−3 −2 −1 0 1 2 3
0.00.20.40.60.81.01.2
hist(Xsum,xlim=c(-3,3),ylim=c(0,1.2),breaks=300,
main=expression(paste(X[t/2]+X[t/2],"'")),
probability=TRUE,col="red")
24. LIST OF EXAMPLES 23
Xt 2 + Xt 2'
Xsum
Density
−3 −2 −1 0 1 2 3
0.00.20.40.60.81.01.2
ks.test(X1,Xsum)
##
## Two-sample Kolmogorov-Smirnov test
##
## data: X1 and Xsum
## D = 0.05, p-value <2e-16
## alternative hypothesis: two-sided
## alpha <- 0.5
## beta <- -0.4
## sigma <- 0.7
## gamma <- 0.5
25. LIST OF EXAMPLES 24
## n <- 1000
## T <- 1.8
## ASmodel <- setModel(drift=0, jump.coeff=1, measure.type="code",
## measure=list(df="rstable(z,alpha,beta,sigma,gamma)"))
## samp <- setSampling(Terminal=T, n=n)
## ASyuima <- setYuima(model=ASmodel, sampling=samp)
## set.seed(129)
## for (i in 1:10) {
## result <- yuima::simulate(ASyuima, true.par=list(alpha=alpha,
## beta=beta,sigma=sigma,gamma=gamma))
## plot(result,xlim=c(0,T),ylim=c(-40,10),col=i,
## main=expression(paste("Paths of stable process (",
## alpha==0.5,",",beta==-0.4,")")),par(new=T))
## }
##
## #param2
## alpha <- 1
## beta <- -0.4
## sigma <- 0.7
## gamma <- 0.5
## AS2model <- setModel(drift=0, jump.coeff=1, measure.type="code",
## measure=list(df="rstable(z,alpha,beta,sigma,gamma)"))
## AS2yuima <- setYuima(model=AS2model, sampling=samp)
## for (i in 1:10) {
## result <- yuima::simulate(AS2yuima, true.par=list(alpha=alpha,
## beta=beta,sigma=sigma,gamma=gamma))
## plot(result,xlim=c(0,T),ylim=c(-5,5),col=i,
## main=expression(paste("Paths of stable process (",
## alpha==1,",",beta==-0.4,")")),par(new=T))
## }
##
## #param3
## alpha <- 1
## beta <- 0.4
## sigma <- 0.7
## gamma <- 0.5
## AS3model <- setModel(drift=0, jump.coeff=1, measure.type="code",
## measure=list(df="rstable(z,alpha,beta,sigma,gamma)"))
## AS3yuima <- setYuima(model=AS3model, sampling=samp)
## for (i in 1:10) {
## result <- yuima::simulate(AS3yuima, true.par=list(alpha=alpha,
## beta=beta,sigma=sigma,gamma=gamma))
## plot(result,xlim=c(0,T),ylim=c(-5,5),col=i,
## main=expression(paste("Paths of stable process (",
## alpha==1,",",beta==0.4,")")),par(new=T))
## }
26. LIST OF EXAMPLES 25
##
## #param4
## alpha <- 1.5
## beta <- 0.4
## sigma <- 0.7
## gamma <- 0.5
## AS4model <- setModel(drift=0, jump.coeff=1, measure.type="code",
## measure=list(df="rstable(z,alpha,beta,sigma,gamma)"))
## AS4yuima <- setYuima(model=AS4model, sampling=samp)
## for (i in 1:10) {
## result <- yuima::simulate(AS4yuima, true.par=list(alpha=alpha,
## beta=beta, sigma=sigma,gamma=gamma))
## plot(result,xlim=c(0,T),ylim=c(-3,5),col=i,
## main=expression(paste("Paths of stable process (",
## alpha==1.5,",",beta==0.4,")")),par(new=T))
## }
Simulation 0.15:.
opar<-par(mar=c(4,4,2,1))
set.seed(129)
for (i in 1:10) {
result <- yuima::simulate(ASyuima, true.par=list(alpha=alpha,
beta=beta,sigma=sigma,gamma=gamma))
plot(result,xlim=c(0,T),ylim=c(-40,10),col=i,
main=expression(paste("Paths of stable process (",
alpha==0.5,",",beta==-0.4,")")),par(new=T))
}
27. LIST OF EXAMPLES 26
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
0.0 0.5 1.0 1.5
−40−30−20−10010
t
x
Paths of stable process (α = 0.5,β = −0.4)
par(opar)
Simulation 0.16:.
#param2
alpha <- 1
beta <- -0.4
sigma <- 0.7
gamma <- 0.5
AS2model <- setModel(drift=0, jump.coeff=1, measure.type="code",
measure=list(df="rstable(z,alpha,beta,sigma,gamma)"))
AS2yuima <- setYuima(model=AS2model, sampling=samp)
28. LIST OF EXAMPLES 27
opar<-par(mar=c(4,4,2,1))
for (i in 1:10) {
result <- yuima::simulate(AS2yuima, true.par=list(alpha=alpha,
beta=beta,sigma=sigma,gamma=gamma))
plot(result,xlim=c(0,T),ylim=c(-5,5),col=i,
main=expression(paste("Paths of stable process (",
alpha==1,",",beta==-0.4,")")),par(new=T))
}
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = −0.4)
par(opar)
opar<-par(mar=c(4,4,2,1))
#param3
29. LIST OF EXAMPLES 28
alpha <- 1
beta <- 0.4
sigma <- 0.7
gamma <- 0.5
AS3model <- setModel(drift=0, jump.coeff=1, measure.type="code",
measure=list(df="rstable(z,alpha,beta,sigma,gamma)"))
AS3yuima <- setYuima(model=AS3model, sampling=samp)
for (i in 1:10) {
result <- yuima::simulate(AS3yuima, true.par=list(alpha=alpha,
beta=beta,sigma=sigma,gamma=gamma))
plot(result,xlim=c(0,T),ylim=c(-5,5),col=i,
main=expression(paste("Paths of stable process (",
alpha==1,",",beta==0.4,")")),par(new=T))
}
30. LIST OF EXAMPLES 29
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
0.0 0.5 1.0 1.5
−4−2024
t
x
Paths of stable process (α = 1,β = 0.4)
par(opar)
#param4
alpha <- 1.5
beta <- 0.4
sigma <- 0.7
gamma <- 0.5
AS4model <- setModel(drift=0, jump.coeff=1, measure.type="code",
measure=list(df="rstable(z,alpha,beta,sigma,gamma)"))
AS4yuima <- setYuima(model=AS4model, sampling=samp)
opar<-par(mar=c(4,4,2,1))
for (i in 1:10) {
31. LIST OF EXAMPLES 30
result <- yuima::simulate(AS4yuima, true.par=list(alpha=alpha,beta=beta,
sigma=sigma,gamma=gamma))
plot(result,xlim=c(0,T),ylim=c(-3,5),col=i,
main=expression(paste("Paths of stable process (",
alpha==1.5,",",beta==0.4,")")),par(new=T))
}
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
0.0 0.5 1.0 1.5
−2024
t
x
Paths of stable process (α = 1.5,β = 0.4)
par(opar)
Simulation 0.17:.
32. LIST OF EXAMPLES 31
modJump <- setModel(drift = c("-theta*x"), diffusion = "sigma",
jump.coeff=c("gamma+x/sqrt(1+x^2)"),
measure = list(intensity="lambda",df=list("dnorm(z, -3, 1)")),
measure.type="CP", solve.variable="x")
modJump
##
## Diffusion process with Levy jumps
## Number of equations: 1
## Number of Wiener noises: 1
## Number of Levy noises: 1
## Parametric model with 4 parameters
samp <- setSampling(n=10^4,Terminal=10)
set.seed(125)
X <- yuima::simulate(modJump, xinit=2, sampling=samp,
true.par= list(theta=2, sigma=0.5,gamma=0.3,lambda=0.5))
0 2 4 6 8 10
−1.00.01.02.0
t
x
x0 <- 2
a <- 0.1
c <- -1
model.ig <- setModel(drift="a*x", xinit=x0, jump.coeff=c,
measure.type="code", measure=list(df="rIG(z, delta0, gamma)"))
model.ig
## Levy process
## Number of equations: 1
## Number of Levy noises: 1
## Parametric model with 3 parameters
38. LIST OF EXAMPLES 37
##
## Average inter-arrival times: 0.325708
##
## Average jump size: 2.002308
##
## Standard Dev. of jump size: 0.796882
##
## Jump Threshold: 0.063096
##
## Summary statistics for jump times:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.33 2.72 6.34 5.61 8.11 9.15
##
## Summary statistics for jump size:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -0.072 1.795 2.335 2.002 2.544 2.742
est.qmle1 <- qmle(yuima=X, start=true,
lower=list(theta=1,sigma=0,gamma=0.1,lambda=0.1),
upper=list(theta=3,sigma=2,gamma=0.8,lambda=20), method="L-BFGS-B",
threshold=2) # too large
summary(est.qmle1)@coef
## Estimate Std. Error
## sigma 1.454 0.0103
## theta 1.978 0.1438
## lambda 1.600 0.4000
## gamma 0.295 0.0155
est.qmle2 <- qmle(yuima=X, start=true,
lower=list(theta=1,sigma=0,gamma=0.1,lambda=0.1),
upper=list(theta=3,sigma=2,gamma=10,lambda=1000), method="L-BFGS-B",
threshold=0.03) ## too low
summary(est.qmle2)@coef
## Estimate Std. Error
## sigma 0.427 0.003188
## theta 1.460 0.045165
## lambda 77.852 2.799724
## gamma 0.111 0.000103
39. Chapter 1
Parameter estimation
1.1 Generator of moments method
Example 1.1: Stochastic discount factor (SDF) for a CAPM.
The general theory in Jagannathan and Skoulakis [2002] implies that E(DtRi,t) = 1 for all
stocks i = 1, . . . , N, where Dt is the SDF and Ri,t the gross return 1 + ri,t. It can be shown
that if the CAPM holds, Dt = θ0 + θ1Rm,t where Rm,t the gross return of the market, which
implies the following moment conditions:
E [Ri,t(θ0 + θ1Rm,t) − 1] = 0 for i = 1, . . . , N
which can be tested as follows:
g <- function(theta, x) {
ret <- (theta[1] + theta[2] * (1 + c(x[, 1]))) * (1 + x[, -1]) - 1
return(ret)
}
Dataset Finance in package gmm Chausse [2017] contains daily returns on selected stocks, the
market portfolio and factors of Fama and French1
from 1993-01-05 to 2009-01-30.
library(gmm)
data("Finance")
x <- Finance[, c("rm", "UIS","ORB","MAT","ABAX","T")]
1
http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html
38