Learn R Programming

Sim.DiffProc (version 2.5)

PredCorr: Predictor-Corrector Method For One-Dimensional SDE

Description

Predictor-Corrector method of simulation numerical solution of one dimensional stochastic differential equation.

Usage

PredCorr(N, M, T = 1, t0, x0, Dt, alpha = 0.5,
         mu = 0.5, drift, diffusion, output = FALSE)

Arguments

N
size of process.
M
number of trajectories.
T
final time.
t0
initial time.
x0
initial value of the process 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.
drift
drift coefficient: an expression of two variables t and x.
diffusion
diffusion coefficient: an expression of two variables t and x.
output
if output = TRUE write a output to an Excel (.csv).

Value

  • data.frame(time,x) and plot of process.

Details

The function returns a trajectory of the process; i.e., x0 and the new N simulated values if M = 1. For M > 1, an mts (multidimensional trajectories) is returned, which means that M independent trajectories are simulated. If Dt is not specified, then Dt = (T-t0)/N. If Dt is specified, then N values of the solution of the sde are generated and the time horizon T is adjusted to be T = N * Dt. The method we present here just tries to approximate the states of the process first. This method is of weak convergence order 1. 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. PredCorr2D predictor-corrector method for two-dimensional SDE.

Examples

Run this code
## example 1
## Hull-White/Vasicek Model
## T = 1 , t0 = 0 and N = 1000 ===> Dt = 0.001 
 drift     <- expression( (3*(2-x)) )
 diffusion <- expression( (2) )
 PredCorr(N=1000, M=1, T = 1, t0=0, x0=10, Dt=0.001, alpha = 0.5,
          mu = 0.5, drift, diffusion, output = FALSE)
## Multiple trajectories of the OU process by Euler Scheme
 PredCorr(N=1000,M=5,T=1,t0=0,x0=10,Dt=0.001,alpha = 0.5,
          mu = 0.5,drift,diffusion,output=FALSE)

Run the code above in your browser using DataLab