options(width=85)

The package intends to implement general simulation of dynamics on (of) networks which have different structural features. The current goal is to simuate ecological interactions among species in ecological networks, as the first instance of complex networks.

Modules should include:

Null models of complex networks (graphs)

The null model of a graph is a randomized version of the original graph. A null model graph matches with the original graph in some of its structural features such as degree distribution or modularity, but is otherwise a completed random graph. Null models of graphs (can) not only serve to identify non-random patterns in real networks, but also highlight(disclose/evaluate) dynamical effects of those patterns.

We implement a null model function for bipartite graphs. A local rewiring algorithm is applied iteratively to generate a null model graph, which keep the degree distribution of the original graph and is otherwise random as much as possible. [@Squartini2011]

require(sdcn)
require(bipartite) # for plot
data(M_PL_003)
# M_PL_003 <- as.matrix(M_PL_003)
bipartite::visweb(M_PL_003)
M_PL_003.rand = swaplinks(M_PL_003)
bipartite::visweb(M_PL_003.rand)

Degree Heterogeneity ...

Dynamics of Ecological Communities

All ecological communities consist of (are made up of) large number of species that interact in myriad (many kinds of) ways with each other. Also all the interacting species in a ecological community are effected by environments such as climate change, and human activities.

How the abundances of species change over time is determined by the complex interactions among species, and the effects of environments on the species. Evolution processes ultimately shape the nature of species interactions and species reaction against environments, that further select survived species.

The dynamics of ecological communities is so complex that it's necessary to simplify some aspects of them [@godfray_open_2014]. Models of dynamics of ecological communities were provided such as ODE models that describe dynamics in deterministic environments, SDE models that describe dynamics in stochastic environments, meta-community and meta-population models that highlight the spacial heterogeneity among communities and populations, individual-based models that emphasize the individuals rather than the population of species.

Different models describe different aspects of ecosystems, and can disclose different aspects of resilience (stability) of ecosystems.

We first implement the ODE model of ecological communities.

A Example of simulation of dynamics of mutualistic communities

The coefficients are same with [@lever_sudden_2014] and [@saavedra_estimating_2013]

library(sdcn)
library(deSolve)
library(rootSolve)
library(plyr)
# the mutualistic network is a empirical network
mutual_graph <- as.matrix(M_PL_003)
s1 = dim(mutual_graph)[1]
s2 = dim(mutual_graph)[2]
mutual_graph <- inc_to_adj(mutual_graph)
# the competitive network include two sub-networks
competitive_graph <- matrix(0, nrow = s1 + s2, ncol = s1 + s2)
competitive_graph[1:s1, 1:s1] = 1
competitive_graph[(s1+1):(s1+s2), (s1+1):(s1+s2)] = 1

coeff <- list(alpha.mu = 0.2, alpha.sd = 0.15, beta0.mu = 0.95, beta0.sd = 0.15, 
              beta1.mu = 0.03, beta1.sd = 0.02, gamma.mu = 1, gamma.sd = 0.2, h.mu = 0.2, h.sd = 0.1, 
              delta = 0.5)  # same with [@saavedra_estimating_2013]

parms <- parms_lv2_cm(mutual_graph, competitive_graph, coeff)
init <- init_lv2_cm(parms)

extinct_threshold <- .Machine$double.eps * 100  # threshold of species
A = sim_ode_auto(model = model_lv2_cm, parms = parms, init = init, steps = 1000, stepwise = 0.1, extinct_threshold = extinct_threshold)
matplot(A$out[1:1000, -1], type = 'l', lwd = 1.)

B = sim_ode_press(model = model_lv2_cm, parms = parms, init = init, steps = 1000, stepwise = 0.1, extinct_threshold = extinct_threshold, perturb = perturb_growthrate, iter_steps = 500, isout = T, r.delta.mu = 0.005, r.delta.sd = 0.)
ode.nstars = laply(B, function(one) {
  one$nstar
})
matplot(ode.nstars, type = 'l', lwd = 1.)

Figures

The figure sizes have been customised so that you can easily put two images side-by-side.

plot(1:10)
plot(10:1)

You can enable figure captions by fig_caption: yes in YAML:

output:
  rmarkdown::html_vignette:
    fig_caption: yes

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.

More Examples

You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using knitr::kable().

knitr::kable(head(mtcars, 10))

Also a quote using >:

"He who gives up [code] safety for [code] speed deserves neither." (via)



keepsimpler/sdcn documentation built on May 20, 2019, 8:45 a.m.