WFP: Simulate Wright-Fisher Process

Description Usage Arguments Value References Examples

Description

Simulate Wright-Fisher Process

Usage

1
2
wfp(nspecies, rho = NULL, lambda = 15, X0 = rho, dt = 1e-05, Tmax = 1,
  nsamples = 1000, method = "VSM", tol = 1e-16)

Arguments

nspecies

One way to parameterize WFP by number of species. rho will be rep(1/nspecies,nspecies)

rho

Compositional vector signifying the mean of the community

lambda

Rate of migration or mean-reversion

X0

optional initial community state - must be a compositional vector of same size as rho

dt

size of timesteps for numerical integration

Tmax

Size of time window of numerical integration

nsamples

Number of timepoints between 0 and T to sample. Output will be a matrix with nrow=length(rho) and ncol=nsamples

method

Method for simulation, either 'VSM' or 'WFP'. Default is VSM - simulates volatility stabilized market and converts to relative abundances.

tol

Tolerance for VSM simulation, i.e. the reflecting lower bound for stock prices to ensure values stay positive.

Value

Outputs a two-element list. The first element is the time vector for the time of samples, and the second element is the matrix of the fluctuating community.

References

Washburne, Alex (2015) "Competition and Coexistence in an Unpredictable World". https://www.academia.edu/15517160/PhD_Thesis_-_Competition_and_Coexistence_in_an_Unpredictable_World

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(WrightFisher)
library(plotrix)

set.seed(1)
X <- wfp(nspecies=5,rho=rep(.2,5),dt=1e-3,Tmax=1)

time <- X$time
X <- X$Community
par(mfrow=c(1,1))
stackpoly(X,stack=T,xlab='time',ylab='Relative Abundance',main='Wright-Fisher Process Trajectory')

reptalex/WrightFisher documentation built on May 27, 2019, 5:54 a.m.