Function library and guide for practicals in Community ecology in R
Basic knowledge of R is useful, but not essential, as all functions are available in a ready-made form. All necessary R commands (and there are only a handful of them) are listed in the table below.
|
|
|
|
|
|
Name |
Function
|
Description
|
Logistický růst jedné populace s volitelnou lag fází.
|
||
logerr |
Logistický růst jedné populace se stochastickou variabilitou.
|
|
Mayova rovnice pro populaci.
|
||
parabolasingle |
Mayova rovnice pro populaci, stavové zobrazení.
|
|
Mayova rovnice pro populaci, animace v závislosti na měnícím
se r.
|
||
Simulace LV dynamiky dvou druhů.
|
||
Isočáry LV dynamiky dvou druhů ve stavovém prostoru.
|
||
Simulace LV dynamiky dvou druhů ve stavovém prostoru s
čarami nulového růstu.
|
||
LV dynamika dvou druhů, response surface podílu
jednoho druhu k hodnotám alfa.
|
||
LV dynamika dvou druhů, response surface diversity
k hodnotám alfa.
|
||
LV dynamika dvou druhů, response surface k počátečním
populačním hustotám.
|
||
Simulace LV dynamiky dvou druhů s disturbancí.
|
||
Dynamika dvou druhů s disturbancí, zobrazení ve stavovém
prostoru.
|
||
Dynamika dvou druhů s disturbancí, response surface podílu
jednoho druhu.
|
||
Dynamika dvou druhů s disturbancí, response surface diversity.
|
||
Simulace LV dynamiky dvou druhů s cyklickou variabilitou
vnějších podmínek (změna K).
|
||
Dynamika dvou druhů s variabilitou vnějších podmínek,
zobrazení ve stavovém prostoru.
|
||
Kompetice o zdroje: Jeden zdroj a jeden nebo více druhů.
|
||
Kompetice o zdroje: Jeden zdroj a jeden druh ve stavovém
grafu s izočárami. Animovaná dynamika.
|
||
Kompetice o zdroje: Jeden zdroj a jeden druh ve stavovém
grafu s izočárami. Měnící se izočáry v závislosti na měnících se parametrech
|
||
Kompetice o zdroje: dva druhy kompetující o jeden zdroj
ve stavovém grafu.
|
||
Kompetice o zdroje: Dva zdroje a jeden nebo více druhů.
|
||
Kompetice o zdroje: Dva zdroje a jeden nebo více druhů,
grafické zobrazení.
|
||
pp_time | Simulace predator-prey dynamiky dvou druhů | |
pp_lines | Isočáry predator-prey dynamiky dvou druhů | |
pp_plot | Simulace predator-prey dynamiky dvou druhů ve stavovém prostoru s čarami nulového růstu. | |
pp_plot_para | Stavový graf predator-prey dynamiky dvou druhů s čarami nulového růstu. Měnící se izočáry v závislosti na měnících se parametrech. | |
pp_shape | Srovnání dvou složek populační dynamiky kořisti - tj. růstu a predace. Funkci lze použít ke zkoumání vlivu jednotlivých parametrů predace na chování kořisti při type III functional response | |
Metapopulační dynamika: Jeden druh na systému diskrétních
stanovišť - základní Function.
|
||
metapop_plot |
Metapopulační dynamika: dynamika jednoho druhu na systému
diskrétních stanovišť v grafu složek Levinsovy rovnice.
|
|
Metapopulační dynamika: Dva druhy na systému diskrétních
stanovišť - základní Function.
|
||
Metapopulační dynamika: stavová dynamika dvou druhů na
systému diskrétních stanovišť - stavový graf s izočárami a animovanou
dynamikou.
|
||
Interakce v explicitním prostoru: Jeden nebo více druhů
v prostorově explicitním systému diskrétních stanovišť.
|
||
Generování teoretického rozložení druhových četností různých
typů.
|
||
Generování jednoho konkrétního společenstva (souboru N
jedinců) z daného rozložení druhových četností.
|
||
Vytvoření species-area křivky.
|
||
Neutrální dynamika metaspolečenstva se speciací.
|
||
Evolution of optimum reproduction
|
||
Plotting fitness response to reproductive effort.
|
Problem | How to do it | Example | Comment |
Function call | name_Function(arguments) |
r = 0.1 or logist(0.1,100,1,0, 100) |
calls function logist (calculates logistic population growth) for intrinsic growth rate 0.1, carrying capacity of 100, initial number of individuals 1, and 100 steps. The first example first assigns parameter values to variables that are used as function arguments, in the second example the constants are given as function parameters directly. Function output is written to the console, but some functions need not return anything. Functions may have additional effects (e.g. drawing plots). NB. Function must be defined before calling. |
Define a function from a data file | function source() |
source("logist.R") |
reads in the fuction(s) stored in the file logist.R This function reads in all functions stored in the given file. NB. In this practical, most of the functions are stored in their own files. NB. Identical effect is attained by opening the file with the function body (logist.R in this case), selecting the script and Edit->Run line or selection |
Assigning value to a variable |
Using = or<- |
a = 3 a <- 3 |
Variable a gets the new value (if it did not exist, it is defined). This can be used to assign scalars, vectors, matrices, lists and other data types (the variable knows its own data type) |
Assigning function output to a variable |
a=name_Function(arguments) |
a = logist(0.1,100,1,0, 100) |
Output of the function logist is not echoed on the console, but stored into a variable (which can be later used, e.g. for plotting) |
Check for value of a variable |
name_variable |
a |
It echoes the value; an error message if the variable does not exist. |
Vector definition | function c() | c(1,2,3,4) | |
Access to vector or matrix elements |
[] |
a[2] |
returns the second element in a |
Generation sequence of numbers |
using : or function seq() |
1:10 seq(1,10,by=2) |
|
Matrix definition | function cbind() nebo rbind() | cbind(1:5,4:8) |
All sequences must be identical - matrix must be rectangular. cbind joins by columns, rbind by rows There are also other options (e.g. function as.matrix) |
Matrix transpose | Function t() |
a=cbind(1:5,4:8) t(a) |
original matrix has 5 rows and 2 columns, new matrix has 2 rows and 5 columns. |
Determine size of a matrix or a vector |
Function length() (for vectors) or function dim() (for matrices) |
a=cbind(1:5,4:8) dim(a) |
Function length for matrices return the total number of matrix elements which is not very useful |
Plot one variable against another variable (simple XY plotting of two variables) |
Function plot(x,y), first argument is for the X axis, the second for the Y axis |
plot(1:5,(1:5)^2) |
If the function has only one argument (e.g. plot((1:5)^2) ), it plots the variable against the index variable (in this case it is equivalent to the expression plot(1:5,(1:5)^2) ) |
Plot several avriables against one variable (twodimensional plot with several series of Y) |
Function matplot(x,y), the first argument is the vector for teh X axis, the second argument is the matrix in which individual columns correspond to series to be plotted on the Y axis |
x=1:5 |
columns correspond to series to be plotted on the Y axis length of the X vector and number of rows of the Y matrix must be equal |
Access to individual elements of a list |
operator $ operator [[]] |
listname$elementname listname[[elementindex]] |
Some functions (neutral, pp_time) return a list as the output (e.g. a vector and a number). In such a case they are linked as a "list". Components of a list can be examined using the function names(listname) . |
Stop current calculation |
Esc or Misc->Stop current computation |
||
List variables in the workarea |
Function objects() or Misc->List objects |
objects() | no arguments, but brackets are necessary |
List files in the working directory | Function dir() | dir() | no arguments, but brackets are necessary |
Check for working directoty |
Function getwd() or File->Change dir |
getwd() |
no arguments, but brackets are necessary |
Cahnge working directory |
Function setwd() or File->Change dir |
setwd(folder_name) |
System:
- dN/dt = rN(K-N)/K .
- Parameters:
- r: intrinsic growth rate (units: 1/time)
- K: carrying capacity (units: number of individuals)
Potentially interesting things:
- zkoumejte, jak závisí dynamika druhu na nosné kapacitě (K), na počáteční populační hustotě (n0), na rychlosti populačního růstu (r)
- zkoumejte, jak závisí dynamika druhu na délce lagfáze a jak se tato závislost mění se změnou rychlosti populačního růstu
- zkoumejte, jak závisí dynamika druhu na variabilitě vnějších podmínek
Functions implementing logistic population growth:
(1) Function logist: Logistc growth of a population with variable lag. The function returns a vector of a length nostep, with time series data on population growth. This has to be plotted using the function plot. Parameters of the function:
- r (intrinsic growth rate)
- K (carrying capacity)
- n0 (initial population size)
- lag (lag: population responds at the time t to population size at the time t-lag-1)
- nostep (počet kroků)
(2) Function logerr: Logistic population growth with stochastic variability. Returns a vector of a length nostep, with time series data on population growth. This has to be plotted using the function plot. Parameters of the function:
- r (intrinsic growth rate)
- K (carrying capacity)
- n0 (initial population size)
- noise (intensity of the stochastic variation lag)
- type (environmental variability type):
- 1: environmental (Gaussovská, parametr noise znamená s.d. podílu počtu individuí)
- 2: Poisson demographic stochasticity
- nostep (number of steps)
(3) Soubor pro volání funkcí calc_logistic. Příklad volání funkcí.
Logistic population growth: May's equation
System:
- N(t+1) = RN(K-N)/K .
- Parameters:
- R: growth rate (units: 1)
- K: carrying capacity (jednotky: number of individuals)
Možná zajímavá zkoumání:
- zkoumejte, jak závisí dynamika druhu na rychlosti populačního růstu (R), případně i na nosné kapacitě (K), na počáteční populační hustotě (n0),
- Zkoumejte vliv stochasticity prostředí (proměnná noise ve funkci maysingle) na časový vývoj populace a na vznik cyklického nebo chaotického chování
- Pozn. Mayova rovnice na rozdíl od rovnice běžného logistického růstu není kumulativní - modeluje chování populace s nepřekrývajícími se generacemi. Proto výsledná populační velikost závisí na R.
Function:
(1) Function maysingle: May's equation. Returns a vector of a length nostep, with time series data on population growth. This has to be plotted using the function plot. Parameters of the function:
(2) Function parabolasingle: May's equation in the state space. Function plots a plot. Parameters:
- R (population growth rate)
- K (carrying capacity)
- noise ( environmental stochasticity)
- n0 (initial population size)
- nostep (number of steps)
- R (population growth rate)
- K (carrying capacity)
- noise ( environmental stochasticity)
- n0 (initial population size)
- nostep (number of steps)
- maxr: range of y(rozsah osy y)
(3) Function may: May's equation with animation: change with the value of r. Function plots a (n animated) plot. Parameters:
- startr (initial R)
- endr (final R)
- stepr (delta R)
- K (carrying capacity)
- noise
- n0 (initial population size)
- nostep (number of steps)
- singleplot (0: no animation; 1: animation of change in time; 2: animation in the state space)
- animation (animation rate)
(4) Soubor pro volání funkcí calc_may. Příklad volání funkcí.
Lotka-Volterra dynamics of two species
System:
- dN1/dt = r1N1(K1-N1-alfa12N2)/K1.
- dN2/dt = r2N2(K2-alfa21N1-N2)/K2.
- Parameters:
- r1, r2: intrinsic growth rates of species 1 and 2 (units: 1/time)
- K1 a K2: carrying capacities of species 1 and 2 (units: number of individuals)
- alfa12: competition coefficient of species 2 to species 1 (units: number of individuals of species 2 / number of individuals of species 1)
- alfa21: competition coefficient of species 1 to species 2 (units: number of individuals of species 1 / number of individuals of species 2)
Lotka-Volterra dynamics of two species: problems to be examined
Functions implementing Lotka-Volterra dynamics:
- examine temporal dynamics of different combinations of K1, K2, alfa12 a alfa21. Use both plotting against time, and state space with both species. Find combiantions corresponding to all basic types of behaviour (stable coexistence, deterministic dominance of one species, founder controlled system)
- alphas are best examined when K1=K2 (dynamics of the system is then determined by alpha <> 1)
- examine effects of r1 a r2.
- for a founder-controlled system examine the role of initial population densities.
(1) Function lv2_time: LV dynamics of two species. (basic function) This function can be used to examine temporal dynamics of the system (x axis time, y axis function values). It returns a 2xnostep matrix with dynamics of both species.Function parameters:
- r1 (intrinsic growth rate of species 1)
- K1 (carrying capacity of the species 1)
- n01 (initial population size of species 1)
- r2 (intrinsic growth rate of species 2)
- K2 (carrying capacity of the species 2)
- n02 (initial population size of species 2)
- alfa12 (effect of species 2 on species 1)
- alfa21 (effect of species 1 on species2)
- nostep (number of steps)
(2) Function lv2_lines: Isolines of LV dynamics in the state space. This function calculates values of isolines of both species, and is only an auxiliary function for the next two. Parameters of the function:
- K1 (carrying capacity of the species 1)
- K2 (carrying capacity of the species 2)
- alfa12 (effect of species 2 on species 1)
- alfa21 (effect of species 1 on species2)
(3) Function lv2_plot: Simulation of LV dynamics of two species in teh state space with zero-growth isolines. (two previous functions must be downloaded to make this function run.) This function plots the state space of the system, draws zero-growths isoclines, and system development trajectory (in red). Function parameters:
- first nine para are identical to lv2_time
- whether to animate system trajectory.
(4) Function lv2_3d: LV dynamics of two species: response surface to values of alfa (all previous functions must be downloaded to make this function run). This function draws a plot showing how (given fixed values of K, a r and initial sizes) final proportion of species 2 depends on alfa12 a alfa21. Parameters of the function:
- r1 (intrinsic growth rate of species 1)
- K1 (carrying capacity of the species 1)
- n01 (initial population size of species 1)
- r2 (intrinsic growth rate of species 2)
- K2 (carrying capacity of the species 2)
- n02 (initial population size of species 2)
- alfaini lower limit of competition coefficients
- alfaend upper limit of competition coefficients
- alfastep step by which competition coefficients are changed
- nostep (number of steps)
(5) Function lv2_3d_divers: LV dynamics of two species: response surface k hodnotám alfa (all previous functions must be downloaded to make this function run). This function draws a plot showing how (given fixed values of K, a r and initial sizes) diversity of the system depends on alfa12 a alfa21. Parameters of the functionare identical as for the lv2_3d function:
- r1 (intrinsic growth rate of species 1)
- K1 (carrying capacity of the species 1)
- n01 (initial population size of species 1)
- r2 (intrinsic growth rate of species 2)
- K2 (carrying capacity of the species 2)
- n02 (initial population size of species 2)
- alfaini lower limit of competition coefficients
- alfaend upper limit of competition coefficients
- alfastep step by which competition coefficients are changed
- nostep (number of steps of the simulation)
(6) Function lv2_3d_ini: LV dynamics of two species: response surface to initial species densities (all previous functions must be downloaded to make this function run). This function draw a plot showing how (for fixed K, alfa and r) proportion of species 2 depends on initial species densities. Function parameters are similar:
- r1 (intrinsic growth rate of species 1)
- K1 (carrying capacity of the species 1)
- r2 (intrinsic growth rate of species 2)
- K2 (carrying capacity of the species 2)
- alfa12 (effect of species 2 on species 1)
- alfa21 (effect of species 1 on species2)
- n0ini lower limit of initial density
- n0end upper limit of initial density
- n0step step by which initial density is changed
- nostep (number of steps of the simulation)
(7) Soubor pro volání funkcí calc_LV. Příklad volání funkcí.
Vliv disturbance na dynamiku a koexistenci dvou druhů
Systém:
- LV rovnice jako v předcházejícím případě
- disturbance (=likvidace určité části jedinců populace) s určitou frekvencí
Problémy ke zkoumání
- zkoumejte, jak závisí převládnutí jednoho druhu či koexistence na růstové rychlosti. Je výhodné pracovat s K1=K2 a takovými alfami, které vedou k převládnutí jednoho druhu nezávisle na počátečních podmínkách (jedna alfa >1 a druhá alfa <1) a při tom měnit růstovou rychlost "slabšího" druhu. Poznámka: v rovnovážném systému růstová rychlost koexistenci neovlivňuje - zkoumejte, jak je to zde.
- zkoumejte totéž pro nastavení četnosti disturbance a odlišné citlivosti obou druhů k disturbanci. Zkuste, jak v systému s jedním rychle rostoucím, ale kompetitivně slabým druhem a jedním pomalu rostoucím, ale kompetitivně silným druhem ovlivní koexistenci/převládnutí jednoho z nich frekvence nebo intensita disturbance.
- zobrazujte systémy jak v závislosti na čase, tak i ve stavovém prostoru
- zkoumejte, zda lze vhodným nastavením růstových rychlostí získat koexistenci dvou druhů i v případě, kdy rovnovážný model ke koexistenci nevede (competition-colonization tradeoff). K hledání parametrů růstových rychlostí a intensity disturbance lze rovněž využít funkcí response surface
Function s disturbancí v LV systémech:
(1) Function lv2_dist: Simulace LV dynamiky dvou druhů s disturbancí. Tato Function je vhodná pro sledování dynamiky systému v čase (na ose x čas, na ose y hodnoty Function). Function vrací matici o rozměru 2xnostep, obsahující časový vývoj obou druhů. Parametry Function:
(2) Function lv2_dist_plot: Dynamika dvou druhů s disturbancí: zobrazení ve stavovém prostoru. Tato Function kreslí obrázek (případně animovaný) ve stavovém prostoru (isočáry a trajektorie vývoje systému). Parametry Function jsou stejné jako v předchozím případě, a jeden parametr navíc (zda animovat).
- r1 (populační růstová rychlost druhu 1)
- K1 (nosná kapcita populace druhu 1)
- n01 (počáteční velikost populace druhu 1)
- r2 (populační růstová rychlost druhu 2)
- K2 (nosná kapacita populace druhu 2)
- n02 (počáteční velikost populace druhu 2)
- alfa12 (působení druhu 2 na druh 1)
- alfa21 (působení druhu 1 na druh 2)
- perioda disturbance (po kolika krocích dojde k disturbanci)
- faktor, na nějž klesne při disturbanci populační velikost druhu 1 (0: úplná likvidace; 1: disturbance na něj nemá vliv)
- faktor, na nějž klesne při disturbanci populační velikost druhu 2
- nostep (počet kroků)
(3) Function lv2_dist_3d: Dynamika dvou druhů s disturbancí: response surface. Tato Function kreslí obrázek, který ukazuje, jak (pro daná K, alfa a frekvenci disturbance) závisí podíl druhu 2 na jeho růstové rychlosti a intensitě disturbance. Parametry Function jsou podobné, jako v předchozím případě, ale je jich trochu víc:
- r1 (populační růstová rychlost druhu 1)
- K1 (nosná kapcita populace druhu 1)
- n01 (počáteční velikost populace druhu 1)
- r2ini (dolní hranice populační růstové rychlosti druhu 2)
- r2end (horní hranice populační růstové rychlosti druhu 2)
- r2step (přírůstek populační růstové rychlosti druhu 2)
- K2 (nosná kapacita populace druhu 2)
- n02 (počáteční velikost populace druhu 2)
- alfa12 (působení druhu 2 na druh 1)
- alfa21 (působení druhu 1 na druh 2)
- perioda disturbance (po kolika krocích dojde k disturbanci)
- dolní hranice faktoru, na nějž klesne při disturbanci populační velikost obou druhů (0: úplná likvidace; 1: disturbance na ně nemá vliv)
- horní hranice faktoru, na nějž klesne při disturbanci populační velikost obou druhů
- přírůstek faktoru
- nostep (počet kroků)
(4) Function lv2_dist_3d_divers: Dynamika dvou druhů s disturbancí: response surface. Tato Function kreslí obrázek, který ukazuje, jak (pro daná K, alfa a frekvenci disturbance) závisí diverzita systému na jeho relativní růstové rychlosti jednoho druhu a intensitě disturbance. Parametry Function jsou podobné, jako v předchozím případě:
- r1 (populační růstová rychlost druhu 1)
- K1 (nosná kapcita populace druhu 1)
- n01 (počáteční velikost populace druhu 1)
- r2ini (dolní hranice populační růstové rychlosti druhu 2)
- r2end (horní hranice populační růstové rychlosti druhu 2)
- r2step (přírůstek populační růstové rychlosti druhu 2)
- K2 (nosná kapacita populace druhu 2)
- n02 (počáteční velikost populace druhu 2)
- alfa12 (působení druhu 2 na druh 1)
- alfa21 (působení druhu 1 na druh 2)
- perioda disturbance (po kolika krocích dojde k disturbanci)
- dolní hranice faktoru, na nějž klesne při disturbanci populační velikost obou druhů (0: úplná likvidace; 1: disturbance na ně nemá vliv)
- horní hranice faktoru, na nějž klesne při disturbanci populační velikost obou druhů
- přírůstek faktoru
- nostep (počet kroků)
(5) Soubor pro volání funkcí calc_LV_dist. Příklad volání funkcí.
Vliv variability vnějších podmínek na dynamiku a koexistenci dvou druhů
Systém:
- LV rovnice jako v předcházejícím případě
- změna nosné kapacity prostředí (K1 a K2) s určitou frekvencí
Problémy ke zkoumání:
- zkoumejte vliv změny vnějších podmínek (změny K) na dynamiku a koexistenci druhů. Zkoumejte, jakou roli v tom hraje frekvence změny (frequ) a jako růstové rychlosti.
Function implementující proměnlivost prostředí v LV systémech
(1) Function lv2_env: Simulace LV dynamiky dvou druhů s cyklickou variabilitou vnějších podmínek (změna K). Tato Function je vhodná pro sledování dynamiky systému v čase (na ose x čas, na ose y hodnoty Function). Function vrací matici o rozměru 2xnostep, obsahující časový vývoj obou druhů. Parametry Function (jsou tři, a první dva z nich jsou vektory!):
- r1 (populační růstová rychlost druhu 1)
- K1 (nosná kapacita populace druhu 1)
- n01 (počáteční velikost populace druhu 1)
- r2 (populační růstová rychlost druhu 2)
- K2 (nosná kapacita populace druhu 2)
- n02 (počáteční velikost populace druhu 2)
- alfa12 (působení druhu 2 na druh 1)
- alfa21 (působení druhu 1 na druh 2)
- perioda změny prostředí (po kolika krocích dojde ke změně prostředí)
- K1': hodnota nosné kapacity druhu 1 po změně prostředí; stará hodnota K1 se uloží a hodnoty se "vymění" znovu při další následující změně prostředí
- K2': hodnota nosné kapacity druhu 2 po změně prostředí
- nostep (počet kroků)
(2) Function lv2_env_plot: Dynamika dvou druhů s variabilitou vnějších podmínek: zobrazení ve stavovém prostoru. Tato Function kreslí obrázek (případně animovaný) ve stavovém prostoru (isočáry a trajektorie vývoje systému). Parametry Function jsou stejné jako v předchozím případě, a jeden parametr navíc (zda animovat).
(3) Soubor pro volání funkcí calc_LV_env. Příklad volání funkcí.
System:
- dR/dt = r1 R (K-R)/K - C(aR2/(1+aThR2))
- dC/dt = cC(aR2/(1+aThR2)) - dC
- Parameters:
- r1: intrinsic growth rate of the prey (units: 1/time)
- K: Carrying caapcity of the prey (units: number of prey individuals)
- c: prey conversion rate (units: predator individuals/prey individuals)
- a: encounter rate (units: 1/(time*prey individuals2)
- Th: handling time (units: time)
- d: mortality of the predator (units: 1/time)
Problems to study
Functions implementing predator-prey dynamics:
- Examine temporal dynamics of the PP system with different parameter combinations. Use both plotting against time, and state space with densities of both species.
- Find parameter combinations that correspond to the three basic behaviours of the system: (i) stable coexistence in a point (dumped oscillations), (ii) unstable dynamics (diverging cycles) and (iii) stable coexistence in a limit cycle. This depends on the position of the intersection of the predator isocline (green) with the prey isocline (blue).
- In order to get reasonable behaviours it is essential to keep in mind dimensions of individual parameters. (Namely, a is to be kept small). The system has no meaningful solution if i c < d.Th (predator has no positive growth rate)
(1) Function pp_time: PP dynamics. (basic function) This function generates system dynamics with given parameters. Function returns 2xnostep matrix, with temporal dynamics of both species. Function parameters:
- r1: intrinsic growth rate of the prey (units: 1/time)
- K: Carrying caapcity of the prey (units: number of prey individuals)
- c: prey conversion rate (units: predator individuals/prey individuals)
- n01: initial population size of the prey
- a: encounter rate (units: 1/(time*prey individuals2)
- Th: handling time (units: time)
- d: mortality of the predator (units: 1/time)
- n02: initial population size of the predator
- nostep: number of steps of the simulation
(2) Function pp_plot: PP dynamics of two species in the state space with zero growth isoclines (it is necessary to download and save the previous function). This function plots state space of the system, draws zero growth isoclines and system trajectory. Parameters of the function:
- first nine parameters are identical to the pp_time
- whether to animate
(3) Function pp_plot_para: Aanalysis of the effects of one parameter on PP dynamics of two species in state space (it is necessary to download and save the function pp_time). This function plots the state space and draws into it a series of isoclines with one parameter changing. Parameters of the function:
- first nine parameters are identical to the pp_time (parameters n01 and n02 are not used, but should be given; also the parameter to be tested must be given, but its value is not used)
- code of the parameter whose efefcts are to be examined (the remaining parameters get their values from the definitions above). Parametry jsou kódovány takto:
- 1: r1 intrinsic growth rate of the prey (units: 1/time)
- 2: K Carrying caapcity of the prey (units: number of prey individuals)
- 4: c prey conversion rate (units: predator individuals/prey individuals)
- 5: a encounter rate (units: 1/(time*prey individuals2)
- 6: Th: handling time (units: time)
- 7: d mortality of the predator (units: 1/time)
- initial value of that parameter
- final value of that parameter
- the value by which it should be incremented in one step
- whether the isoclines are to be animated
(4) Auxiliary function pp_shape: plots the two components of population dynamics of the prey (the first equation above), i.e. growth and mortality through predation as a function of prey density. It is plotted for a given value of predator density, which must be also given in addition to all other parameters. Prey population density increases if the blue line (natality) is above the green line (predation). The function can be used to examine effects of individual parameters in the case of the type III functional response. Function parameters:
- r1: intrinsic growth rate of the prey (units: 1/time)
- K: Carrying caapcity of the prey (units: number of prey individuals)
- c: prey conversion rate (units: predator individuals/prey individuals)
- a: encounter rate (units: 1/(time*prey individuals2)
- Th: handling time (units: time)
- C: population size of the predator (treated as fixed)
(5) Script for function calls calc_pp. Examples of function calls.
Resource competition: one resource
System:
- Population dynamics: dN/dt = N (uR - d).
- Resource dynamics: dR/dt = S - aR - wuRN.
- Parameters and their units:
- S - resource supply. Units: resource/time
- a je resource loss. Jednotky: 1 / time
- w resource consumption per unit growth
- u growth per resource (1/resource.time)
- d species mortality
- [Multispecies system is a simple generalization of this - each species has its own parameters w, u and d]
Problems to study:
- exanime resource dynamics in a system with no species present (equilibrium between resource supply and loss)
- examine effect of resource parameters (supply a loss) on overall amount of resource and population size of the species that depends on that resource.
- examine effects of species parameters (growth per resource, consumption rate, mortality) on the amount of resource and population size. Use both plots against time and state space.
- examine dynamics of the system with two species. Confirm that coexistence of two species with one limiting resource is not possible (unless both species are identical in the u parameters). Use both plots against time and state space.
- NB. Be careful about units of individual parameters. This is a general warning, but it is especially important when working with variables of very different meanings (such as resource and species abundance).
Functions implementing resource-driven growth of one or several species:
(1) Function res1: One resource and one or several species (basic function). This function is useful for plotting dynamics against time. It returns a matrix with n+1 rows (n is number of species), containing amounts of resource through time and abundances of all species through time. Function has six parameters, the second parameter is a vector (if one species is present) or a matrix (if there are more than one species).
- number of species
- vector with four elements that describe species consuption of the resource (if there are more than one species, it is a matrix with 4 columns and number of rows equal to number of species):
- u, per capita natality as a function of resource. Units: 1 / (resource x time).
- w, consumption rate per unit growth. Units: resource / individual.
- d, mortality. Units: unitless (number of individuals / time)
- Initial population size. Units: number of individuals
- S, Resource supply. Units: resource / time.
- a, resource loss. Units: 1 / time (proportion of resource that disppears from the system if no species is present)
- lag: after how many steps a species comes in
- number of steps
(2) Function res1_plot_rsp: One species and one resource in state space with isoclines. This function plots state space. Only one species can be present. It has six parameters, first of which is a vector.
- vector with four elements that describe species consuption of the resource:
- u, per capita natality as a function of resource. Units: 1 / (resource x time).
- w, consumption rate per unit growth. Units: resource / individual.
- d, mortality. Units: unitless (number of individuals / time)
- Initial population size. Units: number of individuals
- S, Resource supply. Units: resource / time.
- a, resource loss. Units: 1 / time (proportion of resource that disppears from the system if no species is present)
- lag: after how many steps a species comes in
- number of steps
- whether to animate
(3) Function res1_plot_para: One resource and one species in a state space with isoclines. This function plots state space with changing isoclines following changes in one parameter. Only one species can be present. It has eight parameters, first of which is a vector.
- vector with four elements that describe species consuption of the resource:
- u, per capita natality as a function of resource. Units: 1 / (resource x time).
- w, consumption rate per unit growth. Units: resource / individual.
- d, mortality. Units: unitless (number of individuals / time)
- Initial population size. Units: number of individuals
- S, Resource supply. Units: resource / time.
- a, resource loss. Units: 1 / time (proportion of resource that disppears from the system if no species is present)
- number of parameter to be changed (the remaining parameters get their values from the species vector above). Parameter coding:
- 1: u (natality)
- 2: w (consumption rate)
- 3: d (mortality)
- 5: S (resource supply)
- 6: a (resource loss)
- initial parameter value
- final parameter value
- step of parameter change
- whether to animate
(4) Function res1_plot_sp2: Two species in the state space. This function plots a state space of two species. Two species must be present. The function has five marameters, first of which is a 2x4 matrix.
- vector with four elements that describe species consuption of the resource:
- u, per capita natality as a function of resource. Units: 1 / (resource x time).
- w, consumption rate per unit growth. Units: resource / individual.
- d, mortality. Units: unitless (number of individuals / time)
- Initial population size. Units: number of individuals
- S, Resource supply. Units: resource / time.
- a, resource loss. Units: 1 / time (proportion of resource that disppears from the system if no species is present)
- lag: after how many steps a species comes in
- number of steps
(3) Script for function calls calc_res1. Examples how to call the functions.
Resource competition: two resources
System:
- Population dynamics:
- dN1/dt = N1 (min(u11R1, u12R2) - d1).
- dN2/dt = N2 (min(u21R1, u22R2) - d2).
- resource dynamics
- dR1/dt = S1 - a1R1 - w11(natality N1) - w12(natalityN2). [Natality is given by the above equations.]
- dR2/dt = S2 - a2R2 - w21(natality N1) - w22(natality N2). [Natality is given by the above equations.]
- Parameters and their units:
- S - resource supply. Units: resource/time
- a je resource loss. Jednotky: 1 / time
- w resource consumption per unit growth
- u growth per resource (1/resource.time)
- d species mortality
Problems to study:
- examine the effects of individual parameters on zero net growth isoclines of species (Help: use only one step so that species dynamics does not bother)
- examine which parameters and how affect initial change of a two-species system
- examine the effect of position of zero-net growth isoclines on stable state of the system. (Help: keep the amount of resource constant and change only isoclines.)
- examine the effect of consumption rates on system dynamics. Help: set up a system in which each species is limited by a different resource and change consumption rates, for both species. Example of potential initial values:
- v=[0.008,0.004,0.4,0.5,0.3,10;0.005,0.01,0.5,0.4,0.3,20] a res2_plot(2,v,100,0.5,100,0.4,100,0.2)
- v=[0.008,0.004,0.5,0.4,0.3,10;0.005,0.01,0.4,0.5,0.3,20] a res2_plot(2,v,100,0.5,100,0.4,100,0.2)
- examine the effect of initial resource supply on species dynamics. zkoumejte, jak závisí vývoj systému na výchozí hladině zdroje. Help: set up a system in which each species is limited by a different resource and change resource supply and consumption rates
- Examine a system with three species.
- NB. Be careful about units in which individual parameters are expressedí!
Functions implementing competition for two resources for two or more species:
(1) Function res2: Two species and one or more species (basic function). This function is useful for plotting dynamics against time. It returns a matrix with n+2 rows (n is number of species), containing amounts of resource through time and abundances of all species through time. Function has seven parameters, the second parameter is a vector (if one species is present) or a matrix (if there are more than one species).
- number of species
- vector with six elements that describe species consuption of the resource (if there are more than one species, it is a matrix with 6 columns and number of rows equal to number of species):
- u1, per capita natality as a function of resource 1. Units: 1 / (resource1 x time).
- u2, per capita natality as a function of resource 2. Units: 1 / (resource2 x time).
- w1, consumption rate of resource 1 per unit growth. Units: resource1 / individual.
- w2, consumption rate of resource 2 per unit growth. Units: resource2 / individual.
- d, mortality. Units: unitless (number of individuals / time)
- Initial population size. Units: number of individuals
- S, Resource 1 supply. Units: resource1 / time.
- a, resource 1 loss. Units: 1 / time (proportion of resource 1 that disppears from the system if no species is present)
- S, Resource 2 supply. Units: resource2 / time.
- a, resource 2 loss. Units: 1 / time (proportion of resource 2 that disppears from the system if no species is present)
- number of steps
(2) Function res2_plot: two resources and one or more species: graphical. This function plots two plots, one state space of resources (with zero net growth isoclines and system trajectory) and plot against time. It has seven parameters, the second parameter is a vector (if one species is present) or a matrix (if there are more than one species).
- number of species
- vector with six elements that describe species consuption of the resource (if there are more than one species, it is a matrix with 6 columns and number of rows equal to number of species):
- u1, per capita natality as a function of resource 1. Units: 1 / (resource1 x time).
- u2, per capita natality as a function of resource 2. Units: 1 / (resource2 x time).
- w1, consumption rate of resource 1 per unit growth. Units: resource1 / individual.
- w2, consumption rate of resource 2 per unit growth. Units: resource2 / individual.
- d, mortality. Units: unitless (number of individuals / time)
- Initial population size. Units: number of individuals
- S, Resource 1 supply. Units: resource1 / time.
- a, resource 1 loss. Units: 1 / time (proportion of resource 1 that disppears from the system if no species is present)
- S, Resource 2 supply. Units: resource2 / time.
- a, resource 2 loss. Units: 1 / time (proportion of resource 2 that disppears from the system if no species is present)
- number of steps
- whether to animate
(3) Script for function calls calc_res2. Examples.
Metapopulation dynamics of one species
System:
- System of discrete habitats, each of which can be either empty or occupied by the species
- NB. Habitats are displayed as a grid, but spatial positions have no meaning - the system is spatially implicit
- dp/dt = ip(1-p) - ep/(1+alfa.e.p), i is immigration rate, e is extinction rate, alfa measure of the rescue effect (for alfa == 0 it is the standard Levins system) and p is the proportion of occupied habitats.
Problems to be studied:
Function implementing metapopulation dynamics of one species:
- time needed to attain equilibrium and equilibrium occupation as functions of immigration and extinction probabilities
- Examine stable state of the system and show its independence on the initial conditions (Poznámka. V této implementaci modelu typicky konvergují k hodnotě větší než je rovnovážná hodnota. Je to proto, že systém je synchronizovaný, napřed se provede extinkce na všech stanovištích a pak imigrace na všech stanovištích - je tedy o půl kroku "přestřeleno")
- effect of habitat number of stochastic variation
- effect of intitial conditions in different types of rescue systems
(1) Function metapop: one species in the system of discrete habitats (basic function). This function simulates dynamics of one species. It returns a vector with successive values of proportion of occupied habitats over time. It optionally plots spatial figure. Parameters of the function:
- immigration rate
- extinction rate
- initial proportion of occupied habitats (0 - one habitat)
- alfa (intensity of the rescue effect)
- number of cell rows/columns (dim^2 is the total habitat numberK)
- whether to plot a spatial plot
- number of simulation steps
- animation: whether to animate
(2) Function metapop_plot: one species in the system of discrete habitats: state space and system dynamicsFunction parameters:
- immigration rate
- extinction rate
- initial proportion of occupied habitats (0 - one habitat)
- alfa (intensity of the rescue effect)
- number of cell rows/columns (dim^2 is the total habitat numberK)
- number of simulation steps
- animation: whether to animate
(3) Script for function calls calc_metapop. Examples.
Metapopulation dynamics of two species
System:
- System of discrete habitats, each of which can be either empty or occupied by one species
- NB. Habitats are displayed as a grid, but spatial positions have no meaning - the system is spatially implicit
- (founder control):
- Dynamics of one species: dp/dt = i1p(1-p-q) - e1p
- Dynamiof the other species: dq/dt = i2q(1-p-q) - e2q
- i is immigration rate, e is extinction rate (indices 1 and 2 refer to parameters of species 1 or 2), and p and q are proportions of habitats occupied by species 1 and 2.
- (dominance control):
- Dynamics of the dominant species: dp/dt = i1p(1-p) - e1p
- Dynamics of the inferior species: dq/dt = i2q(1-p-q) - e2q - i1pq
- When the system is founder controlled, an occupied habitat is never available for colonization by the other species. When it is dominance controlled, dominant species (1 in this case) can invade the habitats occupied by species 2, but reverse does not happen. Therefore the dominance controlled system equations are not symmetrical.
Problems to be studied:
Functions implementing metapopulation dynamics of two species:
- coexistence of both species under different conditions of immigration and extinction
- difference in coexistnce of species under founder and dominance control.
- Differences in these systems given extinction == 0 and extinction > 0
- Effect of initial conditions under founder and dominance control
- Unsing the state space find conditions for colonization-competition tradeoff
(1) Function metapop2: two species in the system of discrete habitats. This function implements Levins' s dynamics of two species in discrete habitats. It returns a 2xn matrix with temporal dynamics of both species. It optionally plots a spatial plot. Function parameters:
- Species 1 (blue)
- immigration rate
- extinction rate
- number of habitats occupied at the beginning (0 - one habitat)
- Species 2 (green)
- immigration rate
- extinction rate
- number of habitats occupied at the beginning (0 - one habitat)
- domcon: 1 dominance control (species 1 (blue) is dominant), 0 founder control
- number of cell rows/columns (dim^2 is the total habitat numberK)
- whether to plot a spatial plot
- number of simulation steps
(2) Function metapop2_plot: State space with zero growth isoclines. This function plots dynamics of two species having on Levins' s dynamics in discrete habitats. Function parameters:
- Species 1 (blue)
- immigration rate
- extinction rate
- number of habitats occupied at the beginning (0 - one habitat)
- Species 2 (green)
- immigration rate
- extinction rate
- number of habitats occupied at the beginning (0 - one habitat)
- domcon: 1 dominance control (species 1 (blue) is dominant), 0 founder control
- number of cell rows/columns (dim^2 is the total habitat numberK)
- whether to plot a spatial plot
- number of simulation steps
(3) Script for function calls calc_metapop2. Examples.
Spatially explicit dynamics of one or several species using a cellular automata approach
System:
- spatial lattice of cells, each of which can be either empty or occupied by one species
- probability that an empty cell is colonized by the species i is the sum:
- longi x frequency of the species i over the whole lattice ("long distance dispersal")
- imii x frequency of the species i in the cell neighbourhood ("short distance dispersal")
- probability that cell occupied by the species i will be occupied by the species j
- imij x frequency of the species j in the cell neighbourhood, given that the element of the interaction matrix, aij = 1
- if there are several candidates for colonization of a cell, one is selected at random
- cell neighbourhood is defined either as von Neumann neighbourhood (four nearest cells - i.e. sharing an edge with the focal cell) or Moore neighbourhood (eight nearest cells - i.e. sharing an edge or a corner with the focal cell)
- probability of extinction of a cell occupied by the species i is exti
- NB. In contrast to all previous models here the state variables are states of individual cells (therefore also the evaluation takes much longer time!)
Problems to be studied:
- in a one-species system find effects of its parameters (imi, ext a long) on survival, population size and spatial pattern. In particular, find minimum imi value that assures long-term survival of the population given fixed ext value (for long==0)
- in a system of two species
- examine the effect of species parameters (imi, ext a long) on population size, coexistence and spatial pattern of species in time.
- examine behaviour of the dominance controlled and founder controlled systems on coexistence (NB: founder-controlled system has an interaction matrix with non-zero elements only on the main diagonal)
- find a system where coexistence is due to colonization-competition tradeoff (it is possible...). It can be attained if one species reproduces and spreads faster (large imi and long), but is competitively weaker. At the same time, the dominant species must have sufficiently high mortality.
- in the system of three species
- examine behaviour of a dominance controlled system as a function of teh topology of teh interaction matrix
- compare transitive ( A>B, B>C, A>C) and intransitive (A>B, B>C, A<C) matrices in coexistence and spatial patterns
- find a system where coexistence is due to colonization-competition tradeoff
Function implementing spatially explicit system using cellular automata:
(1) Function ca1: One or more species in the system of a square lattice with local dynamics. Function returns a list with two elements: (i) abund, a matrix with nospec lines with temporal dynamics of all species, (ii) map, lattice at the end of the simulation. It also can draw spatial plot. Function parameters:
- number of species
- Species parameters: vector with four elements (for nospec == 1) or a matrix with nospec x 4 elements
- immigration rate
- extinction rate
- long distance dispersal
- proportion of initially occupied cells (0 - one cell). It is not used (but must be given) if there is a valid name of the file with initial spatial arrangement (see below).
- Interaction matrix: a matrix with nospec x nospec elements of zeros and ones. If the element ij equals one, it means that the species j is able to invade a cell occupied by the species i. It diagonal elements must be ones.
- number of cell rows - size of the array (dim^2 is the number of cells)
- type of spatial dynamics: 1 - von Neumann neighbourhood (four neighbouring cells interact, i.e. sharing an edge), 2 - Moore neighbourhood (eight neighbouring cells interact, i.e. sharing an edge or a corner)
- whether to draw plots
- number of steps
- animation (in seconds)
- name of the file with initial spatial arrangement. The file must be in the working directory. It has five columns, which contain species number, x coordinate of the lower left corner, y coordinate of the lower left corner, number of cells occupied by the species in the x direction from that corner, number of cells occupied by the species in the ydirection from that corner. If it does not exist, species arrangement is generated using the last species parameter.
(2) Script for function calls calc_ca. Příklad volání Function.
Geometry of species distributions
System:
- a function to calculate fractal dimension of any input matrix using a simple box counting method.
- The input matrix may be (i) a simple geometric object, (ii) a random lattice, (iii) output from a simulation of an ecological process by cellular automaton, (iv) anything else.
- The system is static - analysis of spatial distribution only
Problems to be studied:
Functions implementing fractal dimension:
- Examine fractal (boxcounting) dimension of simple geometric objects,
- Generate random lattices with different densities and examine how fractal dimension changes with the ncreasing density of occupied cells
- Generate spatially explicit dynamical system with one species by cellular automaton (namely systems with high mortality relative to natality) and examine how fractal dimension changes with increasing natality
- Generate two species spatially explicit dynamical system by cellular automaton (namely competition-colonization tradeoff systems) and examine fractal dimension of both species and how it changes with mortality of the dominant species
- Examine three species systems (namely intransitive ones)
(1) Function fdim: Calculate boxcounting dimension of a given matrix. The function returns a scalar value with the boxcounting dimension of the matrix. Parameters:
- a: input matrix. It must be a square matrix of zeros and ones (ones are taken as presences).
- iffig: whether to draw a log block size-log frequency plot
(2) Script to calculate boxcounting dimension of geometric shapes and random lattices calc_fdim. Simple examples.
(3) Script to calculate boxcounting dimension of species simulated by cellular automata calc_fdim_ca. Examples of one and two-species systems (some manual work is needed for three species systems).
Species abundance distributions, species-area relationship and related phenomena
System:
- a homogeneous community with a fixed number of individuals that can belong to one or several species (system of "coloured balls" in a box of fixed size).
- Species pool, ie. set of all species that are available to be drawn into the community
- Individuals of these species are drawn from the species at random, assuming that probabilities of drawing are given by theoretical distribution of abundances
- Theoretical distributions are of several types (geometric, lognormal, Tokeshi power fraction, broken stick)
- NB. Number of individuals is a parameter of the community, whereas number of species is the parameter of the whole system. Number of species in the community is only a passive outcome of drawing individuals from the species pool. (It is a variable, not a parameter.)
- The system is static - no dynamics is modelled
Problems to be studied:
Theoretical distributions of abundances (SAD):
- Compare shapes of individual SAD. Make a plot of several theoretical SAD together. Use the function matplot (an example is in calc_distr)
- Use both linear and logarithmic plots
- For parameter-driven distributions (lognormal and geometric) examine the effect of the parameter on the distribution shape. Examine the effect of species pool (another parameter of the distribution) on distribution shape.
Communities with finite sizes, sampling and species-area relationship (SAR):
Functions implementing SAD and SAR:
- Examine shapes of SAD in communities of different sizes (numbers of individuals). Examine it for different theoretical SAD.
- Examine slope of the species-area relationship for different SAD and different species pool sizes. Identify when communities become saturated. Compare several SAD.
(1) Function distr: Generate theoretical distribution of abundances of different types. . The function returns a vector with cumulative distributions of abundances for the given species pool. Parameters:
- type: distribution type: 1 geometric, 2 lognormal, 3 Tokeshi power fraction, 4 random (broken stick)
- param: distribution parameter
- geometric: ratio of abundances of two successive species (<1)
- lognormal: standard deviation
- power fraction: any number. The distribution is canonical (i.e. no parameter is needed except for the species pool, but the function requires a parameter which has no effect)
- broken stick: dtto
- pool_size: species pool size
(2) Script for function calls calc_distr. Examples.
(3) Function comm: Generate one finite community (a set of N individuals) from the given theoretical abundance distribution. Function returns a vector of absolute abundances (numbers of individuals) of all species in the community and number of species (both elements are linked as a list). Parameters:
- size: community size (number of individuals
- type: distribution type: 1 geometric, 2 lognormal, 3 Tokeshi power fraction, 4 random (broken stick)
- param: distribution parameter
- geometric: ratio of abundances of two successive species (<1)
- lognormal: standard deviation
- power fraction: distribution is canonical (i.e. no parameter is needed, but the function requires a parameter which has no effect)
- broken stick: dtto
- pool_size: species pool size
- ifplot: whether to draw a plot (1: linear, 2: log)
(4) Function SpecArea: Species-area relationship (more accurately relationship of species number and number of individuals)
Function successively draws 'noreal'-times a community of sizes sizemin, sizemin*sizeincrease, sizemin*sizeincrease^2, up to nosizes. It returns 2*nosizes matrix with community size and associated mean number of species and plots linear or logarithmic plot of this relationship.
- sizemin: lowest community size
- sizeincrease: ratio of sizes of two successive communities (> 1)
- nosizes: number of community sizes
- noreal: number of replicate draws for one community size
- type: distribution type: 1 geometric, 2 lognormal, 3 Tokeshi power fraction, 4 random (broken stick)
- param: distribution parameter
- geometric: ratio of abundances of two successive species (<1)
- lognormal: standard deviation
- power fraction: distribution is canonical (i.e. no parameter is needed, but the function requires a parameter which has no effect)
- broken stick: dtto
- pool_size: species pool size
- ifplot: whether to draw a plot (1: linear, 2: log)
(5) Script for function calls calc_comm_specarea. Examples for comm a SpecArea.
Neutral model of community dynamics
System:
- a set of homogeneous local communities (= a metacommunity), each of which is having a fixed size (total number of individuals) which can belong to one or several species.
- individual species do not differ functionally (all have identical growth rate, mortality and migration)
- processes within a local community
- mortality (disturbance): each individual dies with a constant probability in each step
- local natality: after a mortality event, certain number (maxind * dist * growthfr) of individuals in the local community is replaced by local multiplication of species already present in the local community
- migration: in each local community certain number of individuals (maxind *dist *(1 - growthfr) ) is replaced by migration from other local communities. Alternatively it is replaced by drawing from the species pool.
- speciation: at each step, each individual changes into a new species with a given probability (speciation by point mutation)
- Number of individuals is a parameter of the system, whereas number of species is an outcome of the simulation.
- NB. In contrast to the previous system this is a dynamical system. Evolution of the metacommunity is the result of aggregated behaviours of the local communities.
Problems to be studied:
- One community (no migration, no speciation)
- effect of neutral community drift: set a certain number of species at the beginning (certain species pool size and SAD) and examine change of number of species over time; examine the role of disturbance on time to equilibrium.
- examine the final SAD
- A set of communities (a metacommunity with migration, but no speciation)
- examine behaviour of a metacommunity with no speciation. Examine both effect of disturbance and of migration rate (1 - growthfr) on number of specie sin local community, in the metacommunity and on similarity between local communities.
- A set of communities (with migration and speciation)
- add point mutation into the metacommunity, and examine how it affects SAD and final equilibrium
- examine effects of individual m,odel parameters (disturbance, number of local communities, their size, migration and speciation rates) on (i) final equilibrium, a (ii) transient dynamics
- start from both one species and several species.
Function implementing neutral model:
(1) Function neutral. This function models neutral dynamics of a metacommunity (i.e. a set of local communities) with mortality (disturbance), migration, local multiplication and speciation. It draws figures and returns five variables:
- (i) outddend: vector of final SAD
- (ii) outspec: vector with time course of species diversity in teh metacommunity
- (iii) outdd: nostep x maxspec matrix with SAD (total abundances) of the metacommunity over time
- (iv) outfreq: nostep x maxspec marix with SAD (total frequencies) of the metacommunity over time
- (v) outsimp: vector with time course of Simpson's index
NB. These variables are returned as a list. If the output is placed into e.g. a variable a, individual elements of the list can be accessed either by operator $: a$outddend, or using the the operator [[]]: a[[1]]
Parameters of the function:
- maxspec is a technical limit which must be greater than the number of coexisting species at any time. If the number of species exceeds this limit, the simulation will crash. On the other hand, too large values will slow down the simulation.
- nocom: number of local communities in the metacommunity
- maxind: number of individuals in each metacommunity
- dist: mortality (per individual per step)
- growthfr: proportion of local natality out of total number of newly added individuals
- pointrate: speciation frequency by point mutation per individual per step.
- initialization (using function distr, and uses its parameters)
- type: distribution type: 1 geometric, 2 lognormal, 3 Tokeshi power fraction, 4 random (broken stick)
- param: distribution parameter
- geometric: ratio of abundances of two successive species (<1)
- lognormal: standard deviation
- power fraction: any number. The distribution is canonical (i.e. no parameter is needed except for the species pool, but the function requires a parameter here. It just has no effect)
- broken stick: dtto
- pool_size: species pool size (for pure Hubbell process == 1, but can be otherwise)
- number of simulation steps
- iffig: whether to plot
- animation: animation step in seconds (fractions allowed)
System:
- a set of predefined species that differ in their fecundity and mortality; these parameters define their reproductive effort.
- individual species do not differ in anything else
- there is no demographic stochasticity, only proportions of species are modelled (not absolute growth rates)
Problems to be studied:
- Different shapes of the mortality and fecundity functions and coexistence of species with these parameters
Function implementing optimal life strategy evolution:
(1) Function ReproEffort. This function models evolution of optimum life strategies of a set of species with speciation and extinction due to density dependence. It draws figures and returns two variables:
- (i) relative population sizes (proportions) of individual species
- (ii) stable state proportion of juveniles of these species
NB. These variables are returned as a list. If the output is placed into e.g. a variable a, individual elements of the list can be accessed using the the operator [[]]: a[[1]]
Parameters of the function:
- sa - adult mortality
- sj - juvenile mortality
- f - adult fecundity
- iniadults - initial proportions of adults
- nostep - number of steps
- iffig - whether to make figures
(2) Function PlotFitnessTheta. This function plots survival, fecundity and total fitness for individual species (as follows from their definition). It is embedded in the file ReproEffort.R
Parameters of the function:
- sa - adult mortality
- sj - juvenile mortality
- f - adult fecundity
(3) Script for function calls calc_ReprEffort. Script for function calls.
Evolution of optimum reproduction
System:
- a set of species that differ in their reproductive effort (theta), which determines their adult survival and fecundity.
- survival function: s = asa*(1-theta)^alphasa
- fecundity function: F = af*theta^alphaf
- individual species do not differ in anything else
- there is no demographic stochasticity, only proportions of species are modelled (not absolute growth rates)
speciation: at each step, there is a new species formed with a given probability. Its reproductive effort is drawn from a normal distribution with a given sd (one of the simulation parameters), and mean given by the reproductive effort of the species that gave rise to that new species
Problems to be studied:
- Different shapes of the mortality and fecundity functions and evolution of the systems under these constraints
- If alphasa is greater than one, survival function is convex, dtto for fecundity function. These values determine whether the fitness function itself will be convex (with two local maxima at the endpoint values), concave (with one maximum at intermediate reproductive effort) or with an inflexion point (with two local maxima one of them at the endpoint values, the other at intermediate reproductive effort)
Function implementing optimal life strategy evolution:
(1) Function EvolReproEffort. This function models evolution of optimum life strategies of a set of species with speciation and extinction due to density dependence. It draws figures and returns two variables:
- (i) relative population sizes (proportions) of individual species
- (ii) values of reproductive effort of these species
NB. These variables are returned as a list. If the output is placed into e.g. a variable a, individual elements of the list can be accessed using the the operator [[]]: a[[1]]
Parameters of the function:
- asa - multiplicative constant of adult mortality
- alphasa - power of adult mortality
- af - multiplicative constant of adult fecundity
- alphaf - power of adult fecundity
- mutarate - speciation rate
- sdev - standard deviation of the distribution from which the theta of the new species is drawn
- iniadults - initial proportions of individual species (if this is a vector, each element of the vector is one species, and the simulation starts with more than one species)
- theta - reproductive effort of these species (if iniadults is a vector, this must a vector of the same length)
- maxspec - technical limit of maximum species number
- nostep - number of steps
- iffig - whether to make figures
(2) Function PlotFitnessTheta. This function plots survival, fecundity and total fitness as a function of reproductive effort. It is embedded in the file EvolReproEffort.R
Parameters of the function:
- asa - multiplicative constant of adult mortality
- alphasa - power of adult mortality
- af - multiplicative constant of adult fecundity
- alphaf - power of adult fecundity
(3) Script for function calls calc_EvolreproEffort. Script for function calls.
- Use parameter optimization techniques to estimate parameters of ecological models from the data.
- It is necessary to specify the following:
- functional relationship (the model proper)
- initial parameter values (essentially any number, but it is often appripriate if these differ from zero and one)
- measure of fit model to the data ("loss function"), or another approach to assess fit of the model to the data (such as maximum likelihood)
- convergence criteria (how to assess that the two successive fits do not differ and the true minimum was found)
Problems to be studied:
- Generate data on logistic growth using a simple logistic with noise (function logerr.R) with some parameter values and take the resulting data series as the "field data"
- Estimate input parameters using the logistic model
- using nonlinear regression (function nls). This requires that the functional form can be given in a closed form as N = f(t), N being the population size and t being time.
- using explicit parameter optimization (function optim). No closed functional form is necessary.
- Examine how the parameter estimates match the input parameters used to generate the data, plot predicted and observed values of the model
- Examine how the quality of the estimate depends on the type and amount of noise in the system
- Estimate logistic growth parameters from some published data series
- Take some other model to fit some data
(1) Script for function calls calc_fit. Script for function calls necessary for parameter optimization.