Learn R Programming

Sim.DiffProc (version 2.5)

PredCorr2D: Predictor-Corrector Method For Two-Dimensional SDE

Description

Predictor-Corrector method of simulation numerical solution of Two dimensional stochastic differential equations.

Usage

PredCorr2D(N, T = 1, t0, x0, y0, Dt, alpha = 0.5, mu = 0.5, driftx, 
           drifty, diffx, diffy, Step = FALSE, Output = FALSE)

Arguments

N
size of process.
T
final time.
t0
initial time.
x0
initial value of the process X(t) at time t0.
y0
initial value of the process Y(t) at time t0.
Dt
time step of the simulation (discretization).
alpha
weight alpha of the predictor-corrector scheme.
mu
weight mu of the predictor-corrector scheme.
driftx
drift coefficient of process X(t): an expression of three variables t , x and y.
drifty
drift coefficient of process Y(t): an expression of three variables t , x and y.
diffx
diffusion coefficient of process X(t): an expression of three variables t , x and y.
diffy
diffusion coefficient of process Y(t): an expression of three variables t , x and y.
Step
if Step = TRUE ploting step by step.
Output
if output = TRUE write a output to an Excel (.csv).

Value

  • data.frame(time,X(t),Y(t)) and plot of process 2-D.

Details

the system for stochastic differential equation Two dimensional is :$$dX(t) = ax(t,X(t),Y(t))* dt + bx(t,X(t),Y(t))* dWx(t)$$ $$dY(t) = ay(t,X(t),Y(t))* dt + by(t,X(t),Y(t))* dWy(t)$$ with driftx=ax(t,X(t),Y(t)), drifty=ay(t,X(t),Y(t)) and diffx=bx(t,X(t),Y(t)), diffy=by(t,X(t),Y(t)). The method we present here just tries to approximate the states of the process first. This method is of weak convergence order 1. dW1(t) and dW2(t) are brownian motions independent. The predictor-corrector algorithm is as follows. First consider the simple approximation (the predictor), Then choose two weighting coefficients alpha and mu in [0,1] and calculate the corrector.

See Also

diffBridge Creating Diffusion Bridge Models. snssde numerical solution of one-dimensional SDE. snssde2D numerical solution of Two-dimensional SDE. PredCorr predictor-corrector method for one-dimensional SDE.

Examples

Run this code
## Example 1
 driftx <- expression(cos(t*x*y))
 drifty <- expression(cos(t))
 diffx <- expression(0.1)
 diffy <- expression(0.1)
 PredCorr2D(N=5000, T = 1, t0=0, x0=0, y0=0, Dt=0.001, alpha = 0.5, 
            mu = 0.5, driftx, drifty, diffx, diffy, Step = FALSE, 
            Output = FALSE)
## ploting Step by Step
PredCorr2D(N=5000, T = 1, t0=0, x0=0, y0=0, Dt=0.001, alpha = 0.5, 
           mu = 0.5, driftx, drifty, diffx, diffy, Step = TRUE, 
           Output = FALSE)

## Example 2
## BM 2-D
 driftx <- expression(0)
 drifty <- expression(0)
 diffx <- expression(1)
 diffy <- expression(1)
 PredCorr2D(N=5000, T = 1, t0=0, x0=0, y0=0, Dt=0.001, alpha = 0.5, 
            mu = 0.5, driftx, drifty, diffx, diffy, Step = FALSE, 
            Output = FALSE)
## ploting Step by Step
PredCorr2D(N=5000, T = 1, t0=0, x0=0, y0=0, Dt=0.001, alpha = 0.5, 
           mu = 0.5, driftx, drifty, diffx, diffy, Step = TRUE, 
           Output = FALSE)


## Example 3
 driftx <- expression(0.03*t*x-x^3)
 drifty <- expression(0.03*t*y-y^3)
 diffx <- expression(0.1)
 diffy <- expression(0.1)
 PredCorr2D(N=5000, T = 1, t0=0, x0=0, y0=0, Dt=0.001, alpha = 0.5, 
            mu = 0.5, driftx, drifty, diffx, diffy, Step = FALSE, 
            Output = FALSE)
## ploting Step by Step
 PredCorr2D(N=5000, T = 1, t0=0, x0=0, y0=0, Dt=0.001, alpha = 0.5, 
           mu = 0.5, driftx, drifty, diffx, diffy, Step = FALSE, 
           Output = FALSE)

Run the code above in your browser using DataLab