Uses growth, survival, discreteTrans, and environmental transition objects to construct a matrix defining probabilities for transitions between continuous stages (e.g. size) due to growth and survival given both size and environmental state and discrete stages.
NOTE - old createCompoundPmatrix is being deprecated; use makeCompoundPmatrix instead.
numeric, number of environmental classes, defaults to 2.
nBigMatrix
numeric, number of size bins in the P matrix, defaults to 50.
minSize
numeric, minimum size of the P matrix, defaults to -1.
maxSize
numeric, maximum size of the P matrix, defaults to 50.
envMatrix
envMatrix object defining transitions between environmental states
for each size.
growObj
growth object.
survObj
survival object.
discreteTrans
object of class discreteTrans, or numeric.
integrateType
integration type, defaults to "midpoint" (which uses probability density
function); other option is "cumul" (which uses the cumulative density function).
correction
correction type, defaults to none. The first option is constant which will multiply every column of the IPM by a constant sufficient to adjust values to those predicted for survival at that size. The second option is discretizeExtremes which will place all transitions to sizes smaller than minSize into the smallest bin, and transitions to sizes larger than maxSize into the largest bin.
Details
This structure can also be used to define size x age IPMs, where the transition
between ages is reflected by a similar matrix.
Value
an object of class IPMmatrix with dimensions
nBigMatrix * nEnvClass, or if discrete transitions exist
(nBigMatrix + nDisc) * nEnvClass
Author(s)
C. Jessica E. Metcalf, Sean M. McMahon, Roberto Salguero-Gomez, Eelke Jongejans & Cory Merow.
References
For information on P matrix: Caswell. 2001. Matrix population models: construction, analysis, and interpretation. 2nd ed. Sinauer. p110-112.
For habitat x stage modeling:
Tuljapurkar, Horvitz & Pascarella. 2003. The many growth rates and elasticities of populations in random environments. American Naturalist 162: p489-502.
Pascarella & Horvitz. 1998. Hurricane disturbance and the population dynamics of a tropical understory shrub: megamatrix elasticity analysis. Ecology 79: p547-563.
Horvitz & Schemske. 1986. Seed dispersal and environmental heterogeneity in a neotropical herb: A model of population and patch dynamics. In Symposium on frugivores and seed dispersal . (Estrada & Fleming, eds.) Dr. W. Junk Publishers, Dordrecht, Netherlands. pp. 169-186.
For age x size modeling: Garcia, Dahlgren and Ehrlen. 2011. No evidence of senescence in a 300-year-old mountain herb. Journal of Ecology 99, p1424-1430.
For general information:
Easterling, Ellner and Dixon. 2000. Size-specific sensitivity: a new structured population model. Ecology 81, p694-708.
Ellner and Rees. 2006. Integral projection models for species with complex demography. The American Naturalist 167, p410-428.
See Also
makeCompoundFmatrix,makeIPMPmatrix
Examples
# Data with only continuous stage and two habitats
dff <- generateData()
Pmatrix <- makeCompoundPmatrix(minSize = min(dff$size,na.rm = TRUE),
maxSize = max(dff$size,na.rm = TRUE), envMatrix = makeEnvObj(dff),
growObj = makeGrowthObj(dff, Formula = sizeNext~size+size2+covariate),
survObj = makeSurvObj(dff, Formula = surv~size+size2+covariate))
image(1:nrow(Pmatrix), 1:ncol(Pmatrix), t(log(Pmatrix)),
xlab = "Continuous stage (e.g. size) at t",
ylab = "Continuous stage (e.g. size) at t+1", axes = FALSE)
axis(1, at = 1:nrow(Pmatrix), lab = round(rep(Pmatrix@meshpoints,
Pmatrix@nEnvClass), 2))
axis(2, at = 1:nrow(Pmatrix), lab = round(rep(Pmatrix@meshpoints,
Pmatrix@nEnvClass), 2))
abline(h = length(Pmatrix@meshpoints) * (1:Pmatrix@nEnvClass))
abline(v = length(Pmatrix@meshpoints) * (1:Pmatrix@nEnvClass))
# Data with continuous and discrete stages
dff <- generateData(type="discrete")
dff$covariate <- sample(1:3, size = nrow(dff), replace = TRUE)
dff$covariateNext <- sample(1:3, size = nrow(dff), replace = TRUE)
discM <- makeDiscreteTrans(dff)
Pmatrix <- makeCompoundPmatrix(minSize = min(dff$size, na.rm = TRUE),
maxSize = max(dff$size, na.rm = TRUE), envMatrix = makeEnvObj(dff),
growObj = makeGrowthObj(dff, Formula = sizeNext~size+size2+covariate),
survObj = makeSurvObj(dff, Formula = surv~size+size2+covariate),
discreteTrans = discM)
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/makeCompoundPmatrix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: makeCompoundPmatrix
> ### Title: Builds a compound P matrix.
> ### Aliases: makeCompoundPmatrix createCompoundPmatrix
>
> ### ** Examples
>
> # Data with only continuous stage and two habitats
> dff <- generateData()
> Pmatrix <- makeCompoundPmatrix(minSize = min(dff$size,na.rm = TRUE),
+ maxSize = max(dff$size,na.rm = TRUE), envMatrix = makeEnvObj(dff),
+ growObj = makeGrowthObj(dff, Formula = sizeNext~size+size2+covariate),
+ survObj = makeSurvObj(dff, Formula = surv~size+size2+covariate))
>
> image(1:nrow(Pmatrix), 1:ncol(Pmatrix), t(log(Pmatrix)),
+ xlab = "Continuous stage (e.g. size) at t",
+ ylab = "Continuous stage (e.g. size) at t+1", axes = FALSE)
> axis(1, at = 1:nrow(Pmatrix), lab = round(rep(Pmatrix@meshpoints,
+ Pmatrix@nEnvClass), 2))
> axis(2, at = 1:nrow(Pmatrix), lab = round(rep(Pmatrix@meshpoints,
+ Pmatrix@nEnvClass), 2))
> abline(h = length(Pmatrix@meshpoints) * (1:Pmatrix@nEnvClass))
> abline(v = length(Pmatrix@meshpoints) * (1:Pmatrix@nEnvClass))
>
> # Data with continuous and discrete stages
> dff <- generateData(type="discrete")
> dff$covariate <- sample(1:3, size = nrow(dff), replace = TRUE)
> dff$covariateNext <- sample(1:3, size = nrow(dff), replace = TRUE)
> discM <- makeDiscreteTrans(dff)
> Pmatrix <- makeCompoundPmatrix(minSize = min(dff$size, na.rm = TRUE),
+ maxSize = max(dff$size, na.rm = TRUE), envMatrix = makeEnvObj(dff),
+ growObj = makeGrowthObj(dff, Formula = sizeNext~size+size2+covariate),
+ survObj = makeSurvObj(dff, Formula = surv~size+size2+covariate),
+ discreteTrans = discM)
[1] "Dim of envMatrix not equal to nEnvClass. Adjusted to 3"
>
>
>
>
>
> dev.off()
null device
1
>