Learn R Programming

Sim.DiffProc (version 2.5)

WFD: Wright-Fisher Diffusion

Description

Simulation the Wright-Fisher diffusion.

Usage

WFD(N, M, t0, T, x0, gamma1, gamma2, sigma, output = FALSE)

Arguments

N
size of process.
M
number of trajectories.
t0
initial time.
T
final time.
x0
initial value of the process at time t0 (0 < x0 < 1).
gamma1
constant (-gamma1 * X(t) + gamma2 * (1 - X(t)) :drift coefficient), (gamma1 >= 0).
gamma2
constant (-gamma1 * X(t) + gamma2 * (1 - X(t)) :drift coefficient). (gamma2 >= 0)
sigma
constant positive (sigma * sqrt(X(t)*(1-X(t))) :diffusion coefficient).
output
if output = TRUE write a output to an Excel (.csv).

Value

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

Details

The Wright-Fisher diffusion also derives directly from the linear drift class, the discretization dt = (T-t0)/N. In population dynamics frequencies of genes or alleles are studied. It is assumed for simplicity that the population size N is fixed and individuals are of two types: A and a. If individuals of type A mutate to type a with the rate gamma1/N and individuals of type a mutate to type A with the rate gamma2/N, then it is possible to approximate the frequency of type A individuals X(t) by the Wright-Fisher diffusion, given by the stochastic equation : $$dX(t) = (-gamma1 * X(t) + gamma2 * ( 1 - X(t)) ) * dt + sigma * sqrt(X(t)*(1-X(t))) *dW(t)$$ with (-gamma1 * X(t) + gamma2 * ( 1 - X(t)) ) :drift coefficient and sigma * sqrt(X(t)*(1-X(t))) :diffusion coefficient, W(t) is Wiener process.

References

Fima C Klebaner. Introduction to stochastic calculus with application (Second Edition), Imperial College Press (ICP), 2005.

See Also

SLVM Stochastic Lotka-Volterra, FBD Feller Branching Diffusion.

Examples

Run this code
WFD(N=1000,M=1,t0=0,T=1,x0=0.5,gamma1=0,gamma2=0.5,sigma=0.2)

Run the code above in your browser using DataLab