a fecundity object (not necessary for life
expectancy analysis).
clonalObj
a clonality object (not necessary for life
expectancy analysis).
nBigMatrix
numeric, number of bins of size used in the IPM matrix.
minSize
numeric, minimum size used for meshpoints of the IPM matrix.
maxSize
numeric, maximum size used for meshpoints of the IPM matrix.
chosenCov
level or value of the covariate(s) at which sensitivity estimation is desired
discreteTrans
matrix of discrete transitions; or 1 if there is none
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 total fertility 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.
preCensusFec
logical (TRUE or FALSE), indicating whether the fecundity object
represents an interval between pre-breeding or a post-breeding censusses.
Defaults to TRUE (pre-breeding census), meaning that all reproduction
and offspring rates required for the F matrix are embedded in fecObj.
Alternatively, an F matrix based on post-breeding census (preCensusFec=FALSE)
uses postCensusSurvObjFec and postCensusGrowObjFec, to cover the survival and growth
of the parents until the reproduction event. (not necessary for life
expectancy analysis)
postCensusSurvObjFec
survival object representing the survival of the parents until the reproduction event.
If not specified (and preCensusFec = FALSE) it is assumed that all parents survive until the reproduction event. (not necessary for life expectancy analysis)
postCensusGrowObjFec
growth object representing the growth of surviving parents until the reproduction event. If not specified (and preCensusFec = FALSE) it is assumed that the parents do not grow until the reproduction event. (not necessary for life expectancy analysis)
preCensusClonal
logical (TRUE or FALSE), indicating whether the clonality object
represents an interval between pre-breeding or a post-'breeding' censusses.
Defaults to TRUE (pre-'breeding' census), meaning that all clonal propagation
and offspring rates required for the C matrix are embedded in clonalObj.
Alternatively, an C matrix based on post-'breeding' census (preCensusClonal=FALSE)
uses postCensusSurvObjClonal and postCensusGrowObjClonal, to cover the survival and growth
of the parents until the clonal propagation event. (not necessary for life
expectancy analysis)
postCensusSurvObjClonal
survival object representing the survival of the parents until the clonal propagation event.
If not specified (and preCensusClonal = FALSE) it is assumed that all parents survive until
the clonal propagation event. (not necessary for life expectancy analysis)
postCensusGrowObjClonal
growth object representing the growth of surviving parents until the clonal propagation event.
If not specified (and preCensusClonal = FALSE) it is assumed that the parents do not grow until
the clonal propagation event. (not necessary for life expectancy analysis)
delta
size of the perturbation desired
response
whether lambda, R0 or life expectancy of a desired bin (lifeExpect with chosenBin) is required
chosenBin
for analysis of life expectancy, which bin in the IPM Life
expectancy should be compared for
Details
The values returned by sensParam are calculated by first calculating
lambda for the chosen IPM; then modifying the focal parameter c by a
very small amount, c.new=c*(1+delta) (the default for delta =1e-4, but users may specify the value that they want). The function then rebuilds the T and F matrices, and re-calculates lambda. Sensitivity is calculated as:
sens = df(x)/dx = (lam.new-lam)/(c*delta)
i.e., the function estimates the degree to which a small change in the parameter results in a small change in lambda; and elasticity is calculated as:
elas = sens*c/lam = (lam.new-lam)/(lam*delta)
which corresponds to the proportional change in lambda as an outcome
of the proportional change in the parameter; analagous calculations
are used for R0 and life expectancy.
NOTE: in previous versions of IPMpack (pre 2.0), the output of this function was mis-aligned.
Value
sens
a vector of sensitivities of lambda or other variable with names
corresponding to parameters.
elas
a vector of elasticities to lambda or other variable with names
corresponding to parameters.
Note
Modified following code developed by Rees & Rose 2002 (above).
Author(s)
C. Jessica E. Metcalf, Sean M. McMahon, Roberto Salguero-Gomez, Eelke Jongejans & Cory Merow.
References
Rees and Rose. 2002. Evolution of flowering strategies in Oenothera
glazioviana: an integral projection model approach. Proceedings of the Royal Society London Seres B 269, p1509-1515.
See Also
sens, elas
Examples
dff <- generateData()
#lambda
res <- sensParams(growObj = makeGrowthObj(dff),
survObj = makeSurvObj(dff), fecObj = makeFecObj(dff, Transform="log"),
nBigMatrix = 50, minSize = min(dff$size, na.rm=TRUE),
maxSize = max(dff$size, na.rm = TRUE))
par(mfrow = c(2, 1), bty = "l", pty = "m")
barplot(res$sens,
main = expression("Parameter sensitivity of population growth rate "* lambda),
las = 2, cex.names = 0.5)
barplot(res$elas,
main = expression("Parameter elasticity of population growth rate "* lambda),
las = 2, cex.names = 0.5)
#R0
resR0 <- sensParams(growObj = makeGrowthObj(dff),
survObj = makeSurvObj(dff), fecObj = makeFecObj(dff, Transform="log"),
nBigMatrix = 50, minSize = min(dff$size, na.rm=TRUE),
maxSize = max(dff$size, na.rm = TRUE), response="R0")
par(mfrow = c(2, 1), bty = "l", pty = "m")
barplot(resR0$sens,
main = expression("Parameter sensitivity of net reproductive rate R"[0]),
las = 2, cex.names = 0.5)
barplot(resR0$elas,
main = expression("Parameter elasticity of net reproductive rate R"[0]),
las = 2, cex.names = 0.5)
#life expectancy
resLE <- sensParams(growObj = makeGrowthObj(dff),
survObj = makeSurvObj(dff), nBigMatrix = 50,
minSize = min(dff$size, na.rm=TRUE), maxSize = max(dff$size, na.rm =
TRUE), chosenBin=1, response="lifeExpect")
par(mfrow = c(2, 1), bty = "l", pty = "m")
barplot(resLE$sens,
main = expression("Parameter sensitivity of Life Expectancy"*eta[0]),
las = 2, cex.names = 0.5)
barplot(resLE$elas,
main = expression("Parameter elasticity of Life expectancy"*eta[0]),
las = 2, cex.names = 0.5)
# Same as lambda above, but with two fecundity functions
dff$fec2 <- dff$fec>0 #create binomial describing e.g., prob of flowering
dff$fec[dff$fec==0] <- NA #take out zeros to avoid Inf when fit with log
fv1 <- makeFecObj(dff, Formula = c(fec~size+size2,fec2~size),
Transform=c("log","none"),Family = c("gaussian","binomial"))
res <- sensParams(growObj=makeGrowthObj(dff), survObj = makeSurvObj(dff),
fecObj = fv1, nBigMatrix = 50, minSize = min(dff$size, na.rm = TRUE),
maxSize = max(dff$size, na.rm = TRUE))
par(mfrow = c(2, 1), bty = "l", pty = "m")
barplot(res$sens,
main = expression("Parameter sensitivity of population growth rate " *lambda),
las = 2, cex.names = 0.5)
barplot(res$elas,
main = expression("Parameter elasticity of population growth rate " *lambda),
las = 2, cex.names = 0.5)
# Same but with two fecundity functions and a constant
fv1@fecConstants[1] <-0.5
res <- sensParams(growObj = makeGrowthObj(dff), survObj = makeSurvObj(dff),
fecObj = fv1, nBigMatrix = 50, minSize = min(dff$size, na.rm = TRUE),
maxSize = max(dff$size, na.rm = TRUE))
par(mfrow = c(2, 1), bty = "l", pty = "m")
barplot(res$sens,
main = expression("Parameter sensitivity of population growth rate " *lambda),
las = 2, cex.names = 0.5)
barplot(res$elas,
main = expression("Parameter elasticity of population growth rate " *lambda),
las = 2, cex.names = 0.5)
# Same but with a discrete class
dff <- generateData(type="discrete")
res <- sensParams(growObj = makeGrowthObj(dff), survObj = makeSurvObj(dff),
fecObj = makeFecObj(dff), discreteTrans=makeDiscreteTrans(dff),
nBigMatrix = 50, minSize = min(dff$size, na.rm = TRUE),
maxSize = max(dff$size, na.rm = TRUE))
par(mfrow = c(2, 1), bty = "l", pty = "m")
barplot(res$sens,
main = expression("Parameter sensitivity of population growth rate " *lambda),
las = 2, cex.names = 0.5)
barplot(res$elas,
main = expression("Parameter elasticity of population growth rate " *lambda),
las = 2, cex.names = 0.5)
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/sensParams.Rd_%03d_medium.png", width=480, height=480)
> ### Name: sensParams
> ### Title: Estimates sensitivity and elasticity of lambda (or R0, or Life
> ### expectancy of a chosen bin) to parameters underlying an IPM.
> ### Aliases: sensParams
>
> ### ** Examples
>
> dff <- generateData()
>
> #lambda
> res <- sensParams(growObj = makeGrowthObj(dff),
+ survObj = makeSurvObj(dff), fecObj = makeFecObj(dff, Transform="log"),
+ nBigMatrix = 50, minSize = min(dff$size, na.rm=TRUE),
+ maxSize = max(dff$size, na.rm = TRUE))
>
> par(mfrow = c(2, 1), bty = "l", pty = "m")
> barplot(res$sens,
+ main = expression("Parameter sensitivity of population growth rate "* lambda),
+ las = 2, cex.names = 0.5)
> barplot(res$elas,
+ main = expression("Parameter elasticity of population growth rate "* lambda),
+ las = 2, cex.names = 0.5)
>
> #R0
> resR0 <- sensParams(growObj = makeGrowthObj(dff),
+ survObj = makeSurvObj(dff), fecObj = makeFecObj(dff, Transform="log"),
+ nBigMatrix = 50, minSize = min(dff$size, na.rm=TRUE),
+ maxSize = max(dff$size, na.rm = TRUE), response="R0")
>
> par(mfrow = c(2, 1), bty = "l", pty = "m")
> barplot(resR0$sens,
+ main = expression("Parameter sensitivity of net reproductive rate R"[0]),
+ las = 2, cex.names = 0.5)
> barplot(resR0$elas,
+ main = expression("Parameter elasticity of net reproductive rate R"[0]),
+ las = 2, cex.names = 0.5)
>
> #life expectancy
> resLE <- sensParams(growObj = makeGrowthObj(dff),
+ survObj = makeSurvObj(dff), nBigMatrix = 50,
+ minSize = min(dff$size, na.rm=TRUE), maxSize = max(dff$size, na.rm =
+ TRUE), chosenBin=1, response="lifeExpect")
>
> par(mfrow = c(2, 1), bty = "l", pty = "m")
> barplot(resLE$sens,
+ main = expression("Parameter sensitivity of Life Expectancy"*eta[0]),
+ las = 2, cex.names = 0.5)
> barplot(resLE$elas,
+ main = expression("Parameter elasticity of Life expectancy"*eta[0]),
+ las = 2, cex.names = 0.5)
>
> # Same as lambda above, but with two fecundity functions
> dff$fec2 <- dff$fec>0 #create binomial describing e.g., prob of flowering
> dff$fec[dff$fec==0] <- NA #take out zeros to avoid Inf when fit with log
> fv1 <- makeFecObj(dff, Formula = c(fec~size+size2,fec2~size),
+ Transform=c("log","none"),Family = c("gaussian","binomial"))
>
> res <- sensParams(growObj=makeGrowthObj(dff), survObj = makeSurvObj(dff),
+ fecObj = fv1, nBigMatrix = 50, minSize = min(dff$size, na.rm = TRUE),
+ maxSize = max(dff$size, na.rm = TRUE))
>
> par(mfrow = c(2, 1), bty = "l", pty = "m")
> barplot(res$sens,
+ main = expression("Parameter sensitivity of population growth rate " *lambda),
+ las = 2, cex.names = 0.5)
> barplot(res$elas,
+ main = expression("Parameter elasticity of population growth rate " *lambda),
+ las = 2, cex.names = 0.5)
>
> # Same but with two fecundity functions and a constant
> fv1@fecConstants[1] <-0.5
> res <- sensParams(growObj = makeGrowthObj(dff), survObj = makeSurvObj(dff),
+ fecObj = fv1, nBigMatrix = 50, minSize = min(dff$size, na.rm = TRUE),
+ maxSize = max(dff$size, na.rm = TRUE))
>
> par(mfrow = c(2, 1), bty = "l", pty = "m")
> barplot(res$sens,
+ main = expression("Parameter sensitivity of population growth rate " *lambda),
+ las = 2, cex.names = 0.5)
> barplot(res$elas,
+ main = expression("Parameter elasticity of population growth rate " *lambda),
+ las = 2, cex.names = 0.5)
>
> # Same but with a discrete class
> dff <- generateData(type="discrete")
> res <- sensParams(growObj = makeGrowthObj(dff), survObj = makeSurvObj(dff),
+ fecObj = makeFecObj(dff), discreteTrans=makeDiscreteTrans(dff),
+ nBigMatrix = 50, minSize = min(dff$size, na.rm = TRUE),
+ maxSize = max(dff$size, na.rm = TRUE))
[1] "Warning - offspring splitter indicates more than just continuous stages. No fecundity by the discrete stages supplied in fecByDiscrete; assumed that is 0"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
[1] "Warning: fertility values < 0 exist in matrix, consider transforms. Negative values set to zero"
>
> par(mfrow = c(2, 1), bty = "l", pty = "m")
> barplot(res$sens,
+ main = expression("Parameter sensitivity of population growth rate " *lambda),
+ las = 2, cex.names = 0.5)
> barplot(res$elas,
+ main = expression("Parameter elasticity of population growth rate " *lambda),
+ las = 2, cex.names = 0.5)
>
>
>
>
>
>
> dev.off()
null device
1
>