-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbd.rmd
More file actions
133 lines (100 loc) · 4.08 KB
/
bd.rmd
File metadata and controls
133 lines (100 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
layout: page
title: BirthDeath
---
Intro
=====
See also [Introduction to R page](r.export.html).
A new library
=============
The time plots in bd use a "library" called deSolve, which may not be
installed with your version of R. If you are not sure, type:
```
install.packages("deSolve")
```
**You only have to do this once per installation of R.** If you want,
you can skip this step and come back if you get an error saying you do
not have the package deSolve.
Loading
=======
To load `bd`, type:
```{r}
source("https://raw.githubusercontent.com/Bio3SS/Exponential_figures/master/bd.R")
```
This should work if you are connected to the internet. `source` is a
function; it tells R to load some information. The thing inside the
parentheses is an argument; it tells R what information to load.
You can also open [the file](https://raw.githubusercontent.com/Bio3SS/Exponential_figures/master/bd.R) directly.
It's a good idea to open it directly if you want to work on this project somewhere without an internet connection.
Sample plots {#sample_plots}
============
If we say, for example:
``` {r}
bd()
```
Don't worry {#dont_worry}
------------
Depending on how R is set up, it will probably show a blank plot window
first when you run `bd`. Just hit enter to see the first plot, and so
on.
Basic idea {#basic_idea}
==========
We construct a birth rate and a death rate using a starting value (which
is a rate, with units 1/time) and characteristic values for density
dependence ($$D_b$$ and $$D_d$$, for birth and death rates)
and for Allee effects ($$A_b$$ and $$A_d$$). The
characteristic values have units of population size. The idea is roughly
that density dependence is strong when the population is larger than the
characteristic value for density dependence, and Allee effects are
strong when the population is smaller than the characteristic value for
Allee effects.
The equation for per-capita birth rate is $$b(N) = b_0 \exp(-N/D_b) \exp(-A_b/N)$$. The negative signs are because when things get worse the birth rate gets lower. If either $$D_b$$ or $$A_b$$ is set to NULL in R (the default), that term is ignored.
The equation for per-capita death rate is exactly similar, but without the negative signs: when things get worse, the death rate gets higher:
$$d(N) = d_0 \exp(N/D_d) \exp(A_d/N)$$.
By default, `bd()` makes a per-capita growth plot and a total growth
plot. If you give it a starting population, it also simulates and makes
a time plot (see above).
The key thing to get is that the characteristic values have the same
units as the population. When Allee effect parameters get bigger, or
density-dependence parameters get smaller, that means that these effects
kick in sooner, with stronger effects.
Arguments
=========
To see the arguments for bd, type:
``` {r}
args(bd)
```
(units in parens)
Parameters
----------
- `b0`: Per capita birth rate before Allee or DD effects (1/t)
- `bDD` – $$D_b$$: Scale for density-dependent effects on birth
rate (indiv)
- `bAllee` – $$A_b$$: Scale for Allee effects on birth rate
(indiv)
- `d0`: Per capita death rate before Allee or DD effects (1/t)
- `dDD` – $$D_d$$: Scale for density-dependent effects on death
rate (indiv)
- `dAllee` – $$A_d$$: Scale for Allee effects on death rate
(indiv)
Simulation
----------
- `N0`: sets the value of $$N_0$$ for simulations (indiv).
- `MaxTime`: How long to simulate (t)
- `steps`: Number of points to plot in simulation (1)
Rates
-----
- `popMax`: Maximum population to plot for rates (indiv)
- `reportPcTotal`: Report growth rates as **p**er capita, **t**otal
**b**oth or **n**either.
Appearance
----------
- `legendSize` controls the size of the legend. The default is 1, so
use e.g., 0.5 to make the legend half as big.
- `fontSize` controls the size of the labels and numbers along the
axes. It works like `legendSize`.
- `title="My title"` can be used to add a title to your graph.
- `plab="Density of dolphins"` can be used to add to relabel the x
axis of response graphs
- `tlab="time (months)"` can be used to add to relabel the x axis of
time plots