# 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 <[email protected]>
## 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
```
没有合适的资源?快使用搜索试试~ 我知道了~
matlab+人口增长代码-msPVA:用于基于计数的种群生存力分析的R软件包
共29个文件
png:10个
r:6个
rd:3个
需积分: 10 2 下载量 6 浏览量
2021-05-27
15:30:39
上传
评论
收藏 241KB ZIP 举报
温馨提示
matlab +人口增长代码msPVA:基于计数的多站点人口生存力分析的R实现 该软件包为基于计数的多站点种群生存力分析实现了随机模拟,如定量保护生态学(Morris和Doak,2002年)的第11章中所述。 本书中描述的MatLab实现极大地启发了代码。 安装 您在这里有两个选择。 从github.com安装软件包 这使您可以轻松安装更新,可以访问功能帮助文件等。 library( devtools ) devtools :: install_github( " cmartin/msPVA " ) library( msPVA ) 或者您下载源文件并直接运行 在这种情况下,您需要下载然后执行: source( " MultisitePVA.R " ) 这是一种更快但更脏的方式! 尝试一些例子 使用与Morris&Doak中相同的拍板轨道数据 手动定义参数: res <- simulate_ms_pva( leaving_prob = 0.2 , reaching_prob = 0.5 , growth_rate_means = c( 0.043 , - 0.002 , 0 ), gr
资源详情
资源评论
资源推荐
收起资源包目录
msPVA-master.zip (29个子文件)
msPVA-master
man
simulate_ms_pva.Rd 2KB
simulate_ss_pva.Rd 2KB
calculate_params_from_file.Rd 1KB
.gitignore 40B
README.md 5KB
.Rbuildignore 28B
tests
testthat.R 54B
testthat
test.pva.R 3KB
LICENSE 34KB
msPVA.Rproj 359B
DESCRIPTION 714B
inst
examples
ms.Example.R 523B
params.Example.R 406B
ss.Example.R 649B
extdata
PolarBear_Stirling2004.csv 304B
R
MultisitePVA.R 11KB
README_files
figure-html
ssExample-1.png 25KB
unnamed-chunk-4-1.png 20KB
msExample-2.png 30KB
msExample-1.png 20KB
paramsExample-1.png 20KB
paramsExample-2.png 29KB
unnamed-chunk-4-2.png 31KB
unnamed-chunk-3-2.png 31KB
unnamed-chunk-3-1.png 25KB
unnamed-chunk-5-1.png 24KB
.travis.yml 92B
NAMESPACE 251B
README.Rmd 3KB
共 29 条
- 1
weixin_38717031
- 粉丝: 3
- 资源: 912
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0