TSDensity: Density plot from simulation of two-dimensional stochastic...

Description Usage Arguments Examples

View source: R/TSDensity.R

Description

This function creates density plots for the simulation of two-dimensional stochastic differential equations from TSTraj

Usage

1
2
3
TSDensity(mat, dim = 1, xlim = NULL, ylim = NULL, contour.levels = 15,
  col2d = c("blue", "yellow", "orange", "red"), contour.lwd = 0.5,
  contour.lines = TRUE, kde2d.n = 100, xlab = "X", ylab = "Y", ...)

Arguments

mat

a matrix output from TSTraj.

dim

dimensions of the plot; dim = 1 plots simple density histogram or dim = 2 plots the density in state space (i.e., X and Y respectively on the abscissa and ordinate axes).

xlim

numeric vectors of length 2, giving the x coordinate range. Default = NULL automatically sizes plot window.

ylim

numeric vectors of length 2, giving the y coordinate range. Default = NULL automatically sizes plot window.

contour.levels

the number of contour levels for the two-dimensional plots (i.e., when dim = 2).

col2d

vector of colors to be used in the plot.

contour.lwd

line width of contour lines if contour.lines = TRUE.

contour.lines

if TRUE, then black countour lines added to the graph.

kde2d.n

number of grid points in each direction. Can be scalar or a length-2 integer vector. Passes to argument n in kde2d.

xlab

label for x axis when dim = 2. Default is 'X'

ylab

label for y axis when dim = 2. Default is 'Y'

...

passes arguments to plot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
# First, the parameter values, as found in TSTraj
model.state <- c(x = 3, y = 3)
model.sigma <- 0.2
model.deltat <- 0.005
model.time <- 100

# Second, write out the deterministic skeleton of the equations to be simulated, 
# as found in TSTraj
#Example 1 from article
equationx <- "1.54*x*(1.0-(x/10.14)) - (y*x*x)/(1.0 + x*x)"
equationy <- "((0.476*x*x*y)/(1 + x*x)) - 0.112590*y*y"

# Third, run it, as found in TSTraj
ModelOut <- TSTraj(y0 = model.state, time = model.time, deltat = model.deltat, 
	x.rhs = equationx, y.rhs = equationy, sigma = model.sigma)
# Fourth, plot it:
# in 1D
TSDensity(ModelOut, dim = 1)
# in 2D
TSDensity(ModelOut, dim = 2, kde2d.n = 20, xlab = "")

## End(Not run)

QPot documentation built on May 2, 2019, 2:34 p.m.