-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
204 lines (152 loc) · 7.36 KB
/
README.Rmd
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
output: github_document
---
<!-- # Copyright 2024 Province of Alberta -->
<!-- # -->
<!-- # Licensed under the Apache License, Version 2.0 (the "License"); -->
<!-- # you may not use this file except in compliance with the License. -->
<!-- # You may obtain a copy of the License at -->
<!-- # -->
<!-- # http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- # -->
<!-- # Unless required by applicable law or agreed to in writing, software -->
<!-- # distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- # See the License for the specific language governing permissions and -->
<!-- # limitations under the License. -->
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
library(bbousims)
```
# bbousims
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/poissonconsulting/bbousims/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/bbousims/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/bbousims/branch/main/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/bbousims?branch=main)
<!-- badges: end -->
`bbousims` is a package to simulate Boreal Caribou population abundance over time from survival, ageing and birth processes.
Survival and recruitment data from hypothetical composition surveys and collaring are simulated from key sampling parameters.
The output of `bbs_simulate_caribou()` is intended to be used as input data for [bboutools](https://poissonconsulting.github.io/bboutools/) functions for fitting survival and recruitment models and predicting population growth.
In addition, there is more general functionality for simulating population abundance given any set of stages, period duration, and survival, ageing and birth process matrices.
## Installation
You can install the development version of bbousims from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("poissonconsulting/bbousims")
```
## Introduction
### Simulate survival and fecundity rates
Simulate survival rates for each month, year and stage and fecundity rates for each year and stage.
Rates are generated for female stages (female calf, female yearling and female adult).
Female calf and female adult survival rates are specified from separate linear models, whereas female yearling survival is specified as an effect on female adult survival.
```{r}
set.seed(1)
survival <- bbs_survival_caribou(
survival_adult_female = 0.85,
annual_sd_adult_female = 0.2,
trend_adult_female = -0.1,
month_sd_adult_female = 0.1,
survival_calf_female = 0.5,
yearling_effect = 0.05,
nyear = 5
)
fecundity <- bbs_fecundity_caribou(
calves_per_adult_female = 0.7,
annual_sd = 0.1,
nyear = 5
)
```
View expected monthly survival rates ('eSurvival') for adult females (stage 3) by each month and year.
```{r}
survival$eSurvival[, , 3]
```
### Project population
Population is projected from survival and fecundity rates.
Survival occurs at the end of each month and survival, ageing and birth occur at the end of each year, in that order.
Initial population abundance for each stage is determined from the initial number of adult females set by the user and the calculated stable stage distribution (see `bbs_demographic_summary()` for details).
Population abundance for male stages are based on user-provided sex ratios.
```{r}
set.seed(1)
population <- bbs_population_caribou(survival,
fecundity = fecundity,
adult_females = 500,
proportion_adult_female = 0.65
)
```
The output is a matrix with abundance for each period and stage. The first period is the initial population and period 13 is the final month of the first year.
```{r}
# projected population for first year
population[, 1:13]
```
```{r, fig.height=4,fig.width=7}
bbs_plot_population(population)
```
### Simulate abundance, survival and recruitment data
Abundance, survival and recruitment data are simulated from hypothetical composition surveys and collaring, given the survival and fecundity rates used to project the population and a set of key sampling parameters.
The output is a list of lists of the abundance, survival, and recruitment data.frames for each simulation.
```{r}
set.seed(1)
data <- bbs_simulate_caribou(
survival = survival,
fecundity = fecundity,
nsims = 10,
adult_females = 500,
proportion_adult_female = 0.65,
month_composition = 9L,
collared_adult_females = 30,
group_size = 6,
group_coverage = 0.3
)
```
```{r, fig.height=4,fig.width=7}
bbs_plot_population(data)
```
View collar survival data for the first simulation
```{r}
# collar survival data for first simulation
print(data[[1]]$survival)
```
### Work with `bboutools`
The survival and recruitment data.frames in the output of `bbs_simulate_caribou()` are intended to be used as input data for model fitting functions in the [bboutools package]("https://poissonconsulting.github.io/bboutools/).
```{r, eval=FALSE}
# fit model for each simulation
# we set year_start = 1 because we assume the projected population is for the biological year
fits <- lapply(1:length(data), function(x) {
survival <- data[[x]]$survival
bboutools::bb_fit_survival(data = survival, year_start = 1L)
})
```
## Information
Additional information is available from the [bbousims website](https://poissonconsulting.github.io/bbousims/), including more in-depth articles:
- [Get Started with bbousims](https://poissonconsulting.github.io/bbousims/articles/bbousims.html).
- [Work with bboutools](https://poissonconsulting.github.io/bbousims/articles/bboutools.html).
- [General tools (beyond Boreal Caribou)](https://poissonconsulting.github.io/bbousims/articles/general.html).
## bbou Suite
`bbousims` is part of the bbou suite of tools.
Other packages in this suite include:
- [bboudata](https://github.com/poissonconsulting/bboudata)
- [bbouretro](https://github.com/poissonconsulting/bbouretro)
- [bboushiny](https://github.com/poissonconsulting/bboushiny)
- [bboutools](https://github.com/poissonconsulting/bboutools)
## Contribution
Please report any [issues](https://github.com/poissonconsulting/bbousims/issues).
[Pull requests](https://github.com/poissonconsulting/bbousims/pulls) are always welcome.
## Code of Conduct
Please note that the `bbousims` project is released with a [Contributor Code of Conduct](https://poissonconsulting.github.io/bbousims/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
## License
The code is released under the Apache License 2.0
Copyright 2024 Province of Alberta
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.