Skip to content

Commit 537d3eb

Browse files
committed
version 4.8
1 parent e612ecf commit 537d3eb

18 files changed

+879
-439
lines changed

inst/doc/bridgesde.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ options(prompt="R> ",scipen=16,digits=5,warning=FALSE, message=FALSE,
66
width = 70)
77

88
## -------------------------------------------------------------------
9+
set.seed(1234, kind = "L'Ecuyer-CMRG")
910
f <- expression((1-x)/(1-t))
1011
g <- expression(x)
1112
mod <- bridgesde1d(drift=f,diffusion=g,x0=3,y=1,M=1000)
@@ -29,6 +30,7 @@ head(x, n = 3)
2930
knitr::include_graphics(c("Figures/fig03.png","Figures/fig1008.png"))
3031

3132
## -------------------------------------------------------------------
33+
set.seed(1234, kind = "L'Ecuyer-CMRG")
3234
fx <- expression(-(1+y)*x , -(1+x)*y)
3335
gx <- expression(0.2*(1-y),0.1*(1-x))
3436
Sigma <-matrix(c(1,0.3,0.3,1),nrow=2,ncol=2)
@@ -68,6 +70,7 @@ knitr::include_graphics("Figures/fig1011.png")
6870
# }
6971

7072
## -------------------------------------------------------------------
73+
set.seed(1234, kind = "L'Ecuyer-CMRG")
7174
fx <- expression(-4*(1+x)*y, 4*(1-y)*x, 4*(1-z)*y)
7275
gx <- rep(expression(0.2),3)
7376
mod3 <- bridgesde3d(x0=c(0,-1,0.5),y=c(0,-2,0.5),drift=fx,diffusion=gx,M=1000)

inst/doc/bridgesde.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ dX_t = \frac{1-X_t}{1-t} dt + X_t dW_{t},\quad X_{t_{0}}=3 \quad\text{and}\quad
7878
We simulate a flow of $1000$ trajectories, with integration step size $\Delta t = 0.001$, and $x_0 = 3$ at time $t_0 = 0$, $y = 1$ at terminal time $T=1$.
7979

8080
```{r}
81+
set.seed(1234, kind = "L'Ecuyer-CMRG")
8182
f <- expression((1-x)/(1-t))
8283
g <- expression(x)
8384
mod <- bridgesde1d(drift=f,diffusion=g,x0=3,y=1,M=1000)
@@ -134,6 +135,7 @@ $$
134135
We simulate a flow of $1000$ trajectories, with integration step size $\Delta t = 0.01$:
135136

136137
```{r}
138+
set.seed(1234, kind = "L'Ecuyer-CMRG")
137139
fx <- expression(-(1+y)*x , -(1+x)*y)
138140
gx <- expression(0.2*(1-y),0.1*(1-x))
139141
Sigma <-matrix(c(1,0.3,0.3,1),nrow=2,ncol=2)
@@ -205,6 +207,7 @@ dZ_t = 4 (1-Z_{t}) Y_{t} dt + 0.2 dW_{3,t},\quad Z_{t_{0}}=0.5 \quad\text{and}\q
205207
We simulate a flow of $1000$ trajectories, with integration step size $\Delta t = 0.001$.
206208

207209
```{r}
210+
set.seed(1234, kind = "L'Ecuyer-CMRG")
208211
fx <- expression(-4*(1+x)*y, 4*(1-y)*x, 4*(1-z)*y)
209212
gx <- rep(expression(0.2),3)
210213
mod3 <- bridgesde3d(x0=c(0,-1,0.5),y=c(0,-2,0.5),drift=fx,diffusion=gx,M=1000)
@@ -259,4 +262,4 @@ plot(denJ,display="rgl")
259262

260263
1. Bladt, M. and Sorensen, M. (2007). Simple simulation of diffusion bridges with application to likelihood inference for diffusions. Working Paper, University of Copenhagen.
261264

262-
2. Guidoum AC, Boukhetala K (2020). Sim.DiffProc: Simulation of Diffusion Processes. R package version 4.7, URL https://cran.r-project.org/package=Sim.DiffProc.
265+
2. Guidoum AC, Boukhetala K (2020). Sim.DiffProc: Simulation of Diffusion Processes. R package version 4.8, URL https://cran.r-project.org/package=Sim.DiffProc.

inst/doc/bridgesde.html

Lines changed: 96 additions & 33 deletions
Large diffs are not rendered by default.

inst/doc/fitsde.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ options(prompt="R> ",scipen=16,digits=5,warning=FALSE, message=FALSE,
66
width = 70)
77

88
## -------------------------------------------------------------------
9+
set.seed(12345, kind = "L'Ecuyer-CMRG")
910
f <- expression( (1+2*x) ) ; g <- expression( 0.5*x^0.3 )
1011
sim <- snssde1d(drift=f,diffusion=g,x0=2,N=10^4,Dt=10^-4)
1112
mydata <- sim$X
@@ -33,6 +34,7 @@ BIC(fitmod)
3334
confint(fitmod, level=0.95)
3435

3536
## -------------------------------------------------------------------
37+
set.seed(1234, kind = "L'Ecuyer-CMRG")
3638
f <- expression( 3*(2-x) ) ; g <- expression( 0.5 )
3739
sim <- snssde1d(drift=f,diffusion=g,x0=5,Dt=0.01)
3840
HWV <- sim$X
@@ -49,6 +51,7 @@ summary(fitmod)
4951
confint(fitmod,parm=c("theta1","theta2"),level=0.95)
5052

5153
## -------------------------------------------------------------------
54+
set.seed(1234, kind = "L'Ecuyer-CMRG")
5255
f <- expression(-2*x*t) ; g <- expression(0.2*x)
5356
sim <- snssde1d(drift=f,diffusion=g,N=1000,Dt=0.001,x0=10)
5457
mydata <- sim$X
@@ -61,6 +64,7 @@ fitmod <- fitsde(data=mydata,drift=fx,diffusion=gx,start = list(theta1=1,
6164
summary(fitmod)
6265

6366
## -------------------------------------------------------------------
67+
set.seed(1234, kind = "L'Ecuyer-CMRG")
6468
f <- expression(3*t*(sqrt(t)-x)) ; g <- expression(0.3*t)
6569
sim <- snssde1d(drift=f,diffusion=g,M=1,N=1000,x0=2,Dt=0.001)
6670
mydata <- sim$X
@@ -73,6 +77,7 @@ fitmod <- fitsde(data=mydata,drift=fx,diffusion=gx,start = list(theta1=1,
7377
summary(fitmod)
7478

7579
## -------------------------------------------------------------------
80+
set.seed(1234, kind = "L'Ecuyer-CMRG")
7681
f <- expression( 2*x )
7782
g <- expression( 0.3*x^0.5 )
7883
sim <- snssde1d(drift=f,diffusion=g,M=1,N=10000,x0=2,Dt=0.0001)
@@ -137,6 +142,7 @@ Coef
137142
Info
138143

139144
## ----02,fig.env='figure*', fig.cap='The path mean of the solution of the CKLS model with the estimated parameters and real data ',fig.width=6,fig.height=4----
145+
set.seed(1234, kind = "L'Ecuyer-CMRG")
140146
f <- expression( (2.076-0.263*x) )
141147
g <- expression( 0.130*x^1.451 )
142148
mod <- snssde1d(drift=f,diffusion=g,x0=X[1],M=500, N=length(X),t0=1964.471, T=1989.333)

inst/doc/fitsde.Rmd

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ As an example, we consider the Chan-Karolyi-Longstaff-Sanders (CKLS) model:
7070
with $\theta_{1}=1$, $\theta_{2}=2$, $\theta_{3}=0.5$ and $\theta_{4}=0.3$. Before calling `fitsde`, we generate sampled data $X_{t_{i}}$, with $\Delta t =10^{-4}$, as following:
7171

7272
```{r}
73+
set.seed(12345, kind = "L'Ecuyer-CMRG")
7374
f <- expression( (1+2*x) ) ; g <- expression( 0.5*x^0.3 )
7475
sim <- snssde1d(drift=f,diffusion=g,x0=2,N=10^4,Dt=10^-4)
7576
mydata <- sim$X
@@ -129,6 +130,7 @@ volatility $g(x,\theta) = \theta_{3}$,
129130
with $\theta_{1}=3$, $\theta_{2}=2$ and $\theta_{3}=0.5$, we generate sampled data $X_{t_{i}}$, with $\Delta t =10^{-2}$, as following:
130131

131132
```{r}
133+
set.seed(1234, kind = "L'Ecuyer-CMRG")
132134
f <- expression( 3*(2-x) ) ; g <- expression( 0.5 )
133135
sim <- snssde1d(drift=f,diffusion=g,x0=5,Dt=0.01)
134136
HWV <- sim$X
@@ -175,6 +177,7 @@ As an example, we consider the following model:
175177
with: $a(t) = \theta_{1}t$, and we generate sampled data $X_{t_{i}}$, with $\theta_{1}=-2$, $\theta_{2}=0.2$ and time step $\Delta t =10^{-3}$, as following:
176178

177179
```{r}
180+
set.seed(1234, kind = "L'Ecuyer-CMRG")
178181
f <- expression(-2*x*t) ; g <- expression(0.2*x)
179182
sim <- snssde1d(drift=f,diffusion=g,N=1000,Dt=0.001,x0=10)
180183
mydata <- sim$X
@@ -208,6 +211,7 @@ We consider the following Hull-White (extended Vasicek) model:
208211
with: $a(t) = \theta_{1}t$ and $b(t)=\theta_{2}\sqrt{t}$, the volatility depends on time: $\sigma(t)=\theta_{3}t$. We generate sampled data of $X_t$, with $\theta_{1}=3$, $\theta_{2}=1$ and $\theta_{3}=0.3$, time step $\Delta t =10^{-3}$, as following:
209212

210213
```{r}
214+
set.seed(1234, kind = "L'Ecuyer-CMRG")
211215
f <- expression(3*t*(sqrt(t)-x)) ; g <- expression(0.3*t)
212216
sim <- snssde1d(drift=f,diffusion=g,M=1,N=1000,x0=2,Dt=0.001)
213217
mydata <- sim$X
@@ -238,6 +242,7 @@ Let the following models:
238242
We generate data from true model with parameters $\underline{\theta}=(2,0.3,0.5)$, initial value $X_{0}=2$ and $\Delta t =10^{-4}$, as following:
239243

240244
```{r}
245+
set.seed(1234, kind = "L'Ecuyer-CMRG")
241246
f <- expression( 2*x )
242247
g <- expression( 0.3*x^0.5 )
243248
sim <- snssde1d(drift=f,diffusion=g,M=1,N=10000,x0=2,Dt=0.0001)
@@ -317,6 +322,7 @@ Info
317322
In Figure 2 we reports the sample mean of the solution of the CKLS model with the estimated parameters and real data, their empirical $95\%$ confidence bands (from the $2.5th$ to the $97.5th$ percentile), we can proceed as follows:
318323

319324
```{r 02,fig.env='figure*', fig.cap='The path mean of the solution of the CKLS model with the estimated parameters and real data ',fig.width=6,fig.height=4}
325+
set.seed(1234, kind = "L'Ecuyer-CMRG")
320326
f <- expression( (2.076-0.263*x) )
321327
g <- expression( 0.130*x^1.451 )
322328
mod <- snssde1d(drift=f,diffusion=g,x0=X[1],M=500, N=length(X),t0=1964.471, T=1989.333)
@@ -344,9 +350,11 @@ legend("topleft",c("real data","mean path",paste("bound of", 95,"% confidence"))
344350

345351
# References
346352

347-
1. Brouste A, Fukasawa M, Hino H, Iacus SM, Kamatani K, Koike Y, Masuda H, Nomura R,Ogihara T, Shimuzu Y, Uchida M, Yoshida N (2014). The YUIMA Project: A ComputationalFramework for Simulation and Inference of Stochastic Differential Equations." Journal of Statistical Software, 57(4), 1-51. URL http://www.jstatsoft.org/v57/i04.
353+
1. Brouste A, Fukasawa M, Hino H, Iacus SM, Kamatani K, Koike Y, Masuda H, Nomura R,Ogihara T, Shimuzu Y, Uchida M, Yoshida N (2014). The YUIMA Project: A ComputationalFramework for Simulation and Inference of Stochastic Differential Equations." Journal of Statistical Software, 57(4), 1-51. URL https://www.jstatsoft.org/v57/i04.
348354

349-
2. Guidoum AC, Boukhetala K (2020). Sim.DiffProc: Simulation of Diffusion Processes. R package version 4.7, URL https://cran.r-project.org/package=Sim.DiffProc.
355+
2. Guidoum AC, Boukhetala K (2020). "Performing Parallel Monte Carlo and
356+
Moment Equations Methods for Itô and Stratonovich Stochastic
357+
Differential Systems: R Package Sim.DiffProc". Journal of Statistical Software, 96(2), 1--82. https://doi.org/10.18637/jss.v096.i02
350358

351359
3. Iacus SM (2008). Simulation and Inference for Stochastic Differential Equations: With R Examples. Springer-Verlag, New York.
352360

0 commit comments

Comments
 (0)