R: Predicts continuous (e.g. size) stage distribution in the...
predictFutureDistribution
R Documentation
Predicts continuous (e.g. size) stage distribution in the future giving current population's stage distribution.
Description
Function to project a population forwards using an IPM and a starting
environment. The IPM may be structured by continuous (e.g. size) stage alone, or by continuous stage and environment.
vector containing the sizes of the desired starting population.
IPM
an IPMmatrix object (P matrix if only interested in survival projections, P matrix+ F matrix otherwise).
n.time.steps
a numeric defining the number of time steps for which projection is required.
startingEnv
vector defining the desired starting environment, of length one or length startingSizes; ignored if no environmental states are provided; otherwise if the length is less than startingSizes assumes all individuals start in the same environment, given by startingEnv[1].
Details
Currently this does not accept IPMs with discrete stages (e.g. seedbank).
Value
n.new.dist0
starting frequency distribution along meshpoints in IPMmatrix.
n.new.dist
final frequency distribution.
Author(s)
C. Jessica E. Metcalf, Sean M. McMahon, Roberto Salguero-Gomez, Eelke Jongejans & Cory Merow.
Examples
# Define starting population of interest
startPop <- rnorm(1000,2,1)
# Build T and F matrix
dff <- generateData()
Pmatrix <- makeIPMPmatrix(minSize = 1.1*min(dff$size, na.rm = TRUE),
maxSize = 1.1*max(dff$size, na.rm = TRUE), growObj = makeGrowthObj(dff),
survObj = makeSurvObj(dff), correction = "constant")
Fmatrix <- makeIPMFmatrix(minSize = 1.1*min(dff$size, na.rm = TRUE),
maxSize = 1.1*max(dff$size, na.rm = TRUE),
fecObj = makeFecObj(dff, fecConstants = data.frame(est=0.7), Transform="log"),
correction="constant")
# Make an IPMmatrix object containing P matrix + F matrix
# by replacing the P matrix
IPM <- Pmatrix
IPM@.Data <- Pmatrix + Fmatrix
# Project population five steps
a5 <- predictFutureDistribution(startingSizes = startPop, IPM = IPM,
n.time.steps = 5, startingEnv = 1)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(IPMpack)
Loading required package: Matrix
Loading required package: MASS
Loading required package: nlme
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IPMpack/predictFutureDistribution.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predictFutureDistribution
> ### Title: Predicts continuous (e.g. size) stage distribution in the future
> ### giving current population's stage distribution.
> ### Aliases: predictFutureDistribution
>
> ### ** Examples
>
>
> # Define starting population of interest
> startPop <- rnorm(1000,2,1)
>
> # Build T and F matrix
> dff <- generateData()
> Pmatrix <- makeIPMPmatrix(minSize = 1.1*min(dff$size, na.rm = TRUE),
+ maxSize = 1.1*max(dff$size, na.rm = TRUE), growObj = makeGrowthObj(dff),
+ survObj = makeSurvObj(dff), correction = "constant")
> Fmatrix <- makeIPMFmatrix(minSize = 1.1*min(dff$size, na.rm = TRUE),
+ maxSize = 1.1*max(dff$size, na.rm = TRUE),
+ fecObj = makeFecObj(dff, fecConstants = data.frame(est=0.7), Transform="log"),
+ correction="constant")
>
> # Make an IPMmatrix object containing P matrix + F matrix
> # by replacing the P matrix
> IPM <- Pmatrix
> IPM@.Data <- Pmatrix + Fmatrix
>
> # Project population five steps
> a5 <- predictFutureDistribution(startingSizes = startPop, IPM = IPM,
+ n.time.steps = 5, startingEnv = 1)
>
>
>
>
>
> dev.off()
null device
1
>