# msPVA : An R implementation of count-based multi-site population viability analysis
[![DOI](https://zenodo.org/badge/19481/cmartin/msPVA.svg)](https://zenodo.org/badge/latestdoi/19481/cmartin/msPVA)
[![Build Status](https://travis-ci.org/cmartin/msPVA.svg?branch=master)](https://travis-ci.org/cmartin/msPVA)
This package implements a stochastic simulation for a count-based multi-site population viability analysis as described in chapter 11 of Quantitative Conservation Ecology (Morris & Doak, 2002).
Code is highly inspired from the MatLab implementation described in the book.
## Installation
You have two options here.
### Install package from github.com
This allows you to easily install updates, have access to the function help files etc.
```r
library(devtools)
devtools::install_github("cmartin/msPVA")
library(msPVA)
```
### Or you download the source file and run it directly
In this case, you need download [the raw R file](https://raw.githubusercontent.com/cmartin/msPVA/master/R/MultisitePVA.R)
and then execute :
```r
source("MultisitePVA.R")
```
This is a quicker, but dirtier way!
## Try some examples
With the same Clapper rail data as in Morris & Doak
### Definining parameters manually :
```r
res <- simulate_ms_pva(
leaving_prob = 0.2,
reaching_prob = 0.5,
growth_rate_means = c(0.043, -0.002, 0),
growth_rate_vars = c(0.051, 0.041, 0.051),
initial_pops = c(70, 26, 33),
growth_rate_corrs = {matrix(
c( 1.000, 0.995, 0.896,
0.995, 1.000, 0.938,
0.896, 0.938, 1.000),
nrow = 3,
ncol = 3,
byrow = TRUE
)},
K = c(286, 60, 58),
quasi_extinction_thresholds = c(20, 20, 20),
n_years = 50,
n_runs = 100,
with_progress_bar = FALSE
)
print(res)
```
```
This is the deterministic lambda value : 1.0319573564599
And this is the mean stochastic lambda : 0.99642732192589
Below is mean and standard deviation of log lambda :
-0.00367530129674074 0.013982886113063
```
```r
hist(res)
```
![](README_files/figure-html/msExample-1.png)
```r
plot(res)
```
![](README_files/figure-html/msExample-2.png)
### Or ask the package to calculate most of them automatically from a time-series :
With a two-populations polar bear time series from [Stirling et al. 2004](http://arctic.journalhosting.ucalgary.ca/arctic/index.php/arctic/article/view/479/509)
```r
params <- calculate_params_from_file(
system.file("extdata", "PolarBear_Stirling2004.csv", package = "msPVA")
)
```
```
Warning in calculate_params_from_file(system.file("extdata", "PolarBear_Stirling2004.csv", : There were gaps in the time series.
Mean and variance were computed by linear regression.
Correlation matrix was calculated assuming regular intervals.
```
```r
res <- do.call(
"simulate_ms_pva",
c(
params,
list(
K = c(300,200),
leaving_prob = 0.1,
reaching_prob = 0.7,
quasi_extinction_thresholds = c(20, 20),
n_years = 50,
n_runs = 100,
with_progress_bar = FALSE
)
)
)
print(res)
```
```
This is the deterministic lambda value : 1.05786392886293
And this is the mean stochastic lambda : 0.990314335670581
Below is mean and standard deviation of log lambda :
-0.00978931640713308 0.0107011693034957
```
## Run it for a single population
```r
# From a precalculated mean log-lambdas
res <- simulate_ss_pva(
growth_rate_means = 0.043,
growth_rate_vars = 0.051,
initial_pops = 70,
K = 286,
quasi_extinction_thresholds = 20,
n_years = 50,
n_runs = 100
)
print(res)
```
```
Over a 50 years span, the extinction risk of this population is 0.1
And the risk of decline is 0.16
```
```r
hist(res)
```
![](README_files/figure-html/ssExample-1.png)
```r
# From a vector of log-lambdas
res <- simulate_ss_pva(
log_lambdas = c(-0.0503626618483076, -0.0316522478682412, -0.205890697055539,
-0.0407897021414208, 0.151024474883104, -0.141017433696716, 0.105149579850484,
0.104087724782143, 0.18297223483855),
initial_pops = 70,
K = 286,
quasi_extinction_thresholds = 20,
n_years = 50,
n_runs = 100
)
```
## Read the book
If you are to use this package, I highly recommend that you first read chapter 11 from [Quantitative Conservation Ecology (Morris & Doak, 2002)](http://www.sinauer.com/quantitative-conservation-biology-theory-and-practice-of-population-viability-analysis.html), so you understand limitations and assumptions from the underlying model. Managing animal populations should not be taken lightly.
## Problems
Please report any bugs to the [GitHub issue tracker](https://github.com/cmartin/msPVA/issues) and write any questions to <charles.martin1@uqtr.ca>
## Citation
If this code is useful to you, please cite as :
```
Charles A. Martin (2016). msPVA: An R implementation of count-based multi-site population viability
analysis. R package version 0.0.0.9005. https://github.com/cmartin/msPVA. DOI:10.5281/zenodo.34692
```
weixin_38717031
- 粉丝: 3
- 资源: 912
最新资源
- 西门子828D 840Dsl数控程序PLC西门子数控程序中文注释,详细解释介绍 对于维修人员,或者想学习PLC编程的工程师,初学者 西门子828D和840Dsl是西门子公司生产的数控系统,用于控
- 数字化旅社管理:客房收费系统的构建
- HTML5足球运动赛事网站模板源码.zip
- 基于IEEE33节点的配电网重构,采用最优流法开展了配电网重构工作,得到重构方案,应打开的开关数等,同时对比了重构前后的网损和电压结果 -以下内容来源于第三方解读,仅供参考 这段代码是一个用于电力
- 课程设计-基于单片机的单相电度表设计
- asdjhfjsnlkdmv
- 基于python的二手房数据分析完整源码+说明文档+分析报告+数据(高分项目)
- Matlab基于BP神经网络的气象预测,天气预测 BP神经网络具有任意复杂的模式分类能力和优良的多维函数映射能力,解决了简单感知器不能解决的异或(Exclusive OR,XOR)和一些其他问题
- bzzzhsjfsjlg;g;df''d'ffgg
- 跨平台古诗词展演:新媒体系统开发
- SpringCloudAlibaba技术栈-Dubbo
- BIOS刷新工具,笔记本BIOS工具
- 英国电站13台变压器冷却油中溶解气体分析数据数(2010-2015)
- 文化探索:深入了解各地风土人情
- 中国智慧工地行业市场研究(2023)Word(63页).docx
- 智慧建管&智慧工地PPT(33页).pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0