This document was built in Markdown in R 4.0.4 and compiled on 25 February 2021. It covers package lefko3
version 3.3.2.
In this vignette, we will use the lathyrus
dataset to illustrate the estimation of integral projection models. Please see the other vignettes included in package lefko3
, as well as further vignettes posted online on the projects page of the Shefferson lab website. Other vignettes include demonstrations of raw and function-based MPMs, as well as age-by-stage MPMs.
Lathyrus vernus (family Fabaceae) is a long-lived forest herb, native to Europe and large parts of northern Asia. Individuals increase slowly in size and usually flower only after 10-15 years of vegetative growth. Flowering individuals have an average conditional lifespan of 44.3 years (Ehrlen and Lehtila 2002). Lathyrus vernus lacks organs for vegetative spread and individuals are well delimited (Ehrlen 2002). One or several erect shoots of up to 40 cm height emerge from a subterranean rhizome in March and April. Flowering occurs about four weeks after shoot emergence. Shoot growth is determinate, and the number of flowers is determined in the previous year (Ehrlen and Van Groenendael 2001). Individuals sometimes do not produce aboveground structures every year, instead remaining dormant in one season. Lathyrus vernus is self-compatible but requires visits from bumble-bees to produce seeds. Individuals produce few, large seeds and establishment from seeds is relatively frequent (Ehrlen and Eriksson 1996). The pre-dispersal seed predator Bruchus atomarius often consumes a large fraction of developing seeds, and roe deer (Capreolus capreolus) sometimes consume the shoots (Ehrlen and Munzbergova 2009).
Data for this study were collected from six permanent plots in a population of L. vernus located in a deciduous forest in the Tullgarn area, SE Sweden (58.9496 N, 17.6097 E), during 1988–1991 (Ehrlen 1995). The six plots were relatively similar with regard to soil type, elevation, slope, and canopy cover. Within each plot, all individuals were marked with numbered tags that remained over the study period, and their locations were carefully mapped. New individuals were included in the study in each year. Individuals were recorded at least three times every growing season. At the time of shoot emergence, we recorded whether individuals were alive and produced above-ground shoots, and if shoots had been grazed. During flowering, we recorded flower number and the height and diameter of all shoots. At fruit maturation, we counted the number of intact and damaged seeds. To derive a measure of above-ground size for each individual, we calculated the volume of each shoot as \(\pi × (\frac{1}{2} diameter)^2 × height\), and summed the volumes of all shoots. This measure is strongly correlated with the dry mass of aboveground tissues (\(R^2 = 0.924\), \(P < 0.001\), \(n = 50\), log-transformed values; Ehrlén 1995). Size of individuals that had been grazed was estimated based on measures of shoot diameter in grazed shoots, and the relationship between shoot diameter and shoot height in non-grazed individuals. Only individuals with an aboveground volume of more than 230 mm3 flowered and produced fruits during this study. Individuals that lacked aboveground structures in one season but reappeared in the following year were considered dormant. Individuals that lacked aboveground structures in two subsequent seasons were considered dead from the year in which they first lacked aboveground structures. Probabilities of seeds surviving to the next year, and of being present as seedlings or seeds in the soil seed bank, were derived from separate yearly sowing experiments in separate plots adjacent to each subplot (Ehrlen and Eriksson 1996).
Here we will build historical and ahistorical integral projection models (IPMs). An IPM is a kind of function-based MPM in which transitions are modeled on a continuous state variable rather than discrete stages (Ellner and Rees 2006). A size metric is often used as this continuous state variable. In practice, all size-classified matrix projection models including IPMs require discrete size classes. So, although size is modeled as conforming to the Gaussian distribution, the actual stages developed break size up into many fine-scale, equally sized classes or bins. Although the number of these bins varies from analysis to analysis, package lefko3
uses a default of 100 (this can be changed as an option). Because vital rates are modeled rather than directly calculated from the data, the number of individuals moving through any particular size class at any particular time does not need to be considered in determining stage boundaries (as they would be in raw MPM estimation). IPMs are often complex, meaning that they include some life history stages that fall outside of the size classifications developed for the matrices, such as dormant seeds or juveniles. Package lefko3
can handle all of this complexity.
The dataset that we have provided is organized in horizontal format, meaning that each row holds all of the data for a single, unique individual, and columns correspond to individual condition in particular observation times (which we refer to as years here, since there was one main census in each year). The original Excel spreadsheet used to keep the dataset has a repeating pattern to these columns, with each year having a similarly arranged group of variables. Package lefko3
includes functions to handle data in horizontal format based on these patterns, as well as functions to handle vertically formatted data (i.e. data for individuals is broken up across rows, where each row is a unique combination of individual and year in time t).
Figure 6.1. Organization of the Lathyrus dataset, as viewed in Microsoft Excel.
This dataset includes information on 1,119 individuals, so there are 1,119 rows with data (not counting the header). There are 38 columns. The first two columns are variables giving identifying information about each individual (SUBPLOT
refers to the patch, and GENET
refers to individual identity), with each individual’s data entirely restricted to one row. This is followed by four sets of nine columns, each named VolumeXX
, lnVolXX
, FCODEXX
, FlowXX
, IntactseedXX
, Dead19XX
, DormantXX
, Missing19XX
, and SeedlingXX
, where XX
corresponds to the year of observation and with years organized consecutively. Thus, columns 3-11 refer to year 1988, columns 12-20 refer to year 1989, etc. For lefko3
to handle this dataset correctly, we need to know the exact number of years used, which is 4 years here (includes all years from and including 1988 to 1991), we need the columns to be repeated in the same order for each year, and we need years in consecutive order with no extra columns between them.
First, we clear memory and load the dataset.
rm(list=ls(all=TRUE))
library(lefko3)
data(lathyrus)
To begin, we need to create a stageframe for this dataset. A stageframe is a data frame that describes all stages in the life history of the organism, in a way usable by the functions in this package and using stage names and classifications that completely match those used in the dataset. It needs to include complete descriptions of all stages that occur in the dataset, with each stage defined uniquely. Since this object can be used for automated classification of individuals, all sizes, reproductive states, and other characteristics defining each stage in the dataset need to be accounted for explicitly. This can be difficult if a few data points exist outside the range of sizes specified in the stageframe, so great care must be taken to include all size values and values of other descriptor variables occurring within the dataset. The final description of each stage occurring in the dataset must not completely overlap with any other stage also found in the dataset, although partial overlap is allowed and expected. We will base our stageframe on the life history model provided in Ehrlén (2000), but use a different size classification to allow IPM construction and make all mature stages other than vegetative dormancy reproductive.
In the stageframe code below, we show that we want an IPM by choosing two stages that serve as the size limits for IPM size classification. These two size classes should have exactly the same characteristics in the stageframe other than size. By choosing these two size limits, we can skip adding and describing the many size classes that will fall between these limits - function sf_create()
will create all of these for us. We mark these limits in the vector that we load into the stagenames
option using the string ipm
. Package lefko3
will then create and name all IPM size classes according to its own conventions. The default number of size classes is 100 bins. We can alter this if we wish using the ipmbins
option.
<- c(0, 100, 0, 1, 7100)
sizevector <- c("Sd", "Sdl", "Dorm", "ipm", "ipm")
stagevector <- c(0, 0, 0, 1, 1)
repvector <- c(0, 1, 0, 1, 1)
obsvector <- c(0, 0, 1, 1, 1)
matvector <- c(1, 1, 0, 0, 0)
immvector <- c(1, 0, 0, 0, 0)
propvector <- c(0, 1, 1, 1, 1)
indataset <- c(0, 100, 0.5, 1, 1)
binvec
<- sf_create(sizes = sizevector, stagenames = stagevector,
lathframeipm repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
immstatus = immvector, indataset = indataset, binhalfwidth = binvec,
propstatus = propvector, ipmbins = 100, roundsize = 3)
We will also add some descriptive comments to this stageframe so that we know what each of these stages is, and then look at the first 6 entries and the dimenstions of the stageframe.
$comments <- c("Dormant seed", "Seedling", "Dormant", rep("ipm adult stage", 100))
lathframeipmhead(lathframeipm)[,1:6]
#> stage size repstatus obsstatus propstatus immstatus
#> 1 Sd 0.000 0 0 1 1
#> 2 Sdl 100.000 0 1 0 1
#> 3 Dorm 0.000 0 0 0 0
#> 4 sz36.495 rp1 mt1 ob1 36.495 1 1 0 0
#> 5 sz107.485 rp1 mt1 ob1 107.485 1 1 0 0
#> 6 sz178.475 rp1 mt1 ob1 178.475 1 1 0 0
head(lathframeipm)[,7:12]
#> matstatus indataset binhalfwidth_raw min_age max_age sizebin_min
#> 1 0 0 0.000 NA NA 0.00
#> 2 0 1 100.000 NA NA 0.00
#> 3 1 1 0.500 NA NA -0.50
#> 4 1 1 35.495 NA NA 1.00
#> 5 1 1 35.495 NA NA 71.99
#> 6 1 1 35.495 NA NA 142.98
head(lathframeipm)[,13:16]
#> sizebin_max sizebin_center sizebin_width comments
#> 1 0.00 0.000 0.00 Dormant seed
#> 2 200.00 100.000 200.00 Seedling
#> 3 0.50 0.000 1.00 Dormant
#> 4 71.99 36.495 70.99 ipm adult stage
#> 5 142.98 107.485 70.99 ipm adult stage
#> 6 213.97 178.475 70.99 ipm adult stage
This stageframe has 103 stages (we can see this by typing dim(lathframeipm)
, which will show the numbers of rows and columns, respectively). The IPM portion technically starts with the fourth stage and keeps going through the 103rd stage. Stage names within this range are concatenations of the size centroid (designated with sz
), reproductive status (designated with rp
), maturity status (designated with mt
), and observation status (designated with ob
). The first three stages, which fall outside of the IPM classification, are left unaltered.
To work with this dataset, we first need to format the data into vertical format, in which each row corresponds to the state of a single individual in two (if ahistorical) or three (if historical) consecutive time intervals. Because this is an IPM, we will need to estimate linear models of vital rates, and that will require that NAs in size and fecundity are avoided in key terms used in estimation. For this purpose, we will set NAas0 = TRUE
. We will also set NRasRep = TRUE
because all adult stages other than dormancy are assumed to be reproductive, and there are mature individuals in the dataset that do not reproduce but need to be included in reproductive stages (setting this option to TRUE makes sure that the reproductive status of non-reproductive individuals in potentially reproductive stages is set to 1, although the actual fecundity is not altered). Finally, we will ignore patches this time and estimate matrices only for the full population, in order to preserve statistical power for vital rate modeling in historical IPM analysis.
<- verticalize3(lathyrus, noyears = 4, firstyear = 1988,
lathvertipm individcol = "GENET", blocksize = 9, juvcol = "Seedling1988",
sizeacol = "Volume88", repstracol = "FCODE88", fecacol = "Intactseed88",
deadacol = "Dead1988", nonobsacol = "Dormant1988", stageassign = lathframeipm,
stagesize = "sizea", censorcol = "Missing1988",censorkeep = NA, censor = TRUE,
NAas0 = TRUE, NRasRep = TRUE)
Before we move on to the next key steps in analysis, let’s take a closer look at fecundity. In this dataset, fecundity is mostly a count of intact seeds, and only differs in six cases where the seed output was estimated based on other models. To see this, try the following code.
writeLines(paste0("Total length of variable corresponding to fecundity in time t+1: ", length(lathvertipm$feca3)))
#> Total length of variable corresponding to fecundity in time t+1: 2527
writeLines(paste0("Total non-integer entries in fecundity in time t+1: ", length(which(lathvertipm$feca3 != round(lathvertipm$feca3)))))
#> Total non-integer entries in fecundity in time t+1: 0
writeLines(paste0("\nTotal length of variable corresponding to fecundity in time t: ", length(lathvertipm$feca2)))
#>
#> Total length of variable corresponding to fecundity in time t: 2527
writeLines(paste0("Total non-integer entries in fecundity in time t: ", length(which(lathvertipm$feca2 != round(lathvertipm$feca2)))))
#> Total non-integer entries in fecundity in time t: 6
writeLines(paste0("\nTotal length of variable corresponding to fecundity in time t-1: ", length(lathvertipm$feca1)))
#>
#> Total length of variable corresponding to fecundity in time t-1: 2527
writeLines(paste0("Total non-integer entries in fecundity in time t-1: ", length(which(lathvertipm$feca1 != round(lathvertipm$feca1)))))
#> Total non-integer entries in fecundity in time t-1: 6
$feca3 <- round(lathvertipm$feca3)
lathvertipm$feca2 <- round(lathvertipm$feca2)
lathvertipm$feca1 <- round(lathvertipm$feca1) lathvertipm
Although we wish to treat fecundity as a count, it is still not clear what underlying distribution we should use. This package currently allows 5 choices: Gaussian, Poisson, negative binomial, zero-inflated Poisson, and zero-inflated negative binomial. To assess which to use, we should first assess whether the mean and variance of the count are equal using a dispersion test. The Poisson distribution assumes that the mean and variance are equal, and so we can test this assumption using a chi-squared test. If it is not significantly different, then we may use some variant of the Poisson distribution. If the data are significantly over- or under-dispersed, then we should use the negative binomial distribution. We should also test whether the number of zeroes is significantly greater than expected under these distributions, and make the distribution zero-inflated if so.
Let’s start off by looking at a plot of the distribution of fecundity.
hist(subset(lathvertipm, repstatus2 == 1)$feca2, main = "Fecundity",
xlab = "Intact seeds produced in time t")
Figure 6.2. Histogram of fecundity in time t
We see that the distribution seems to conform to a classic count variable with a very low mean value. The first bar suggests that there may be too many zeroes, and we can see this in the following plot, which focuses in on the leftmost portion of the above graph.
hist(subset(lathvertipm, repstatus2 == 1)$feca2[which(subset(lathvertipm,
== 1)$feca2 < 11)], main = "Fecundity",
repstatus2 xlab = "Intact seeds produced in time t")
Figure 6.3. Histogram of fecundity in time t, only cases with <10 seeds produced
This is fairly ample evidence that we should use a zero-inflated distribution of some sort. But to make that decision, let’s now go to a formal test of the two assumptions of \(mean = variance\) and no excess 0s. Both tests use chi-squared distribution-based approaches, with the zero-inflation test based on van der Broek (1995).
sf_distrib(lathvertipm, fec = "feca2", repst = "repstatus2")
#>
#> Mean fecundity is 4.791
#> The variance in fecundity is 70.14
#> The probability of this dispersion level by chance assuming the true mean fecundity = variance in fecundity is 0
#>
#> Fecundity is significantly overdispersed.
#>
#>
#> Mean lambda is 0.008302
#> The actual number of 0s in fecundity is 334
#> The expected number of 0s in fecundity under the null hypothesis is 4.973
#> The probability of this deviation in 0s is 0
#>
#> Fecundity is significantly zero-inflated.
#> NULL
Such significant results for both tests show us that we really need to use a zero-inflated negative binomial distribution here.
We encourage users to explore the reorganized dataset, which now includes 2527 historical transitions (rows) and 42 variables (columns). Now we move on to create the extra bits of information needed for matrix estimation.
Now we will create supplemental tables, which provide extra data for matrix estimation that is not included in the main demographic dataset. Specifically, we will provide the seed dormancy probability and germination rate, which are given as transitions from the dormant seed stage to another year of seed dormancy or to the germinated seedling stage, respectively. We assume that the germination rate is the same regardless of whether the seed was produced in the previous year or has been in the seedbank for longer. We will incorporate these terms both as fixed constants for specific transitions within the resulting matrices, and as multipliers for fecundity, since ultimately fecundity will be estimated as the production of seed multiplied by the seed germination rate or the seed dormancy/survival rate. We will start with the ahistorical case, and then move on to the historical case, where we also need to input the corresponding stages in time t-1 for each transition.
<- supplemental(stage3 = c("Sd", "Sdl", "Sd", "Sdl"),
lathsupp2 stage2 = c("Sd", "Sd", "rep", "rep"),
givenrate = c(0.345, 0.054, NA, NA),
multiplier = c(NA, NA, 0.345, 0.054),
type = c(1, 1, 3, 3), stageframe = lathframeipm, historical = FALSE)
<- supplemental(stage3 = c("Sd", "Sd", "Sdl", "Sd", "Sdl"),
lathsupp3 stage2 = c("Sd", "Sd", "Sd", "rep", "rep"),
stage1 = c("Sd", "rep", "rep", "all", "all"),
givenrate = c(0.345, 0.345, 0.054, NA, NA),
multiplier = c(NA, NA, NA, 0.345, 0.054),
type = c(1, 1, 1, 3, 3), stageframe = lathframeipm, historical = TRUE)
Integral projection models (IPMs) require functions of vital rates to populate them. Here, we will develop these functions as linear models using modelsearch()
. This looks similar to the modelsearch
call in the last example, although we will not include models of reproductive status because we assume that all adults are reproductive (though perhaps not successfully so). First we will create the historical models in order to assess whether history is a significant influence on vital rates.
<- modelsearch(lathvertipm, historical = TRUE, approach = "mixed",
lathmodels3ipm suite = "size", vitalrates = c("surv", "obs", "size", "fec"),
juvestimate = "Sdl", bestfit = "AICc&k", sizedist = "gaussian",
fecdist = "negbin", fec.zero = TRUE, indiv = "individ", year = "year2",
year.as.random = TRUE, juvsize = TRUE, show.model.tables = TRUE, quiet = TRUE)
#> Warning: Some predictor variables are on very different scales: consider rescaling
#> Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 0.0158034 (tol =
#> 0.002, component 1)
#> Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
#> - Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio
#> - Rescale variables?
#> Warning: Some predictor variables are on very different scales: consider rescaling
#> boundary (singular) fit: see ?isSingular
#> Warning: Some predictor variables are on very different scales: consider rescaling
#> boundary (singular) fit: see ?isSingular
#> Warning in Matrix::sparseMatrix(dims = c(0, 0), i = integer(0), j = integer(0), : 'giveCsparse' has been deprecated; setting 'repr = "T"'
#> for you
#> Warning in Matrix::sparseMatrix(dims = c(0, 0), i = integer(0), j = integer(0), : 'giveCsparse' has been deprecated; setting 'repr = "T"'
#> for you
#> Warning in Matrix::sparseMatrix(dims = c(0, 0), i = integer(0), j = integer(0), : 'giveCsparse' has been deprecated; setting 'repr = "T"'
#> for you
#> Warning in fitTMB(TMBStruc): Model convergence problem; non-positive-definite Hessian matrix. See vignette('troubleshooting')
#> boundary (singular) fit: see ?isSingular
#> boundary (singular) fit: see ?isSingular
summary(lathmodels3ipm)
#> This LefkoMod object includes 7 linear models.
#> Best-fit model criterion used: AICc&k
#>
#> ────────────────────────────────────────────────────────────────────────────────
#> Survival model:
#> Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
#> Family: binomial ( logit )
#> Formula: alive3 ~ sizea1 + (1 | year2) + (1 | individ)
#> Data: surv.data
#> AIC BIC logLik deviance df.resid
#> 910.3733 933.2409 -451.1866 902.3733 2242
#> Random effects:
#> Groups Name Std.Dev.
#> individ (Intercept) 0.2571
#> year2 (Intercept) 0.6149
#> Number of obs: 2246, groups: individ, 257; year2, 3
#> Fixed Effects:
#> (Intercept) sizea1
#> 2.589549 0.001786
#> optimizer (Nelder_Mead) convergence code: 0 (OK) ; 0 optimizer warnings; 3 lme4 warnings
#>
#> ────────────────────────────────────────
#>
#> Observation model:
#> Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
#> Family: binomial ( logit )
#> Formula: obsstatus3 ~ (1 | year2) + (1 | individ)
#> Data: obs.data
#> AIC BIC logLik deviance df.resid
#> 1353.5346 1370.5136 -673.7673 1347.5346 2118
#> Random effects:
#> Groups Name Std.Dev.
#> individ (Intercept) 0.01967
#> year2 (Intercept) 0.00000
#> Number of obs: 2121, groups: individ, 254; year2, 3
#> Fixed Effects:
#> (Intercept)
#> 2.235
#> optimizer (Nelder_Mead) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings
#>
#> ────────────────────────────────────────
#>
#> Size model:
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: sizea3 ~ sizea1 + sizea2 + (1 | year2) + (1 | individ) + sizea1:sizea2
#> Data: size.data
#> REML criterion at convergence: 29132.25
#> Random effects:
#> Groups Name Std.Dev.
#> individ (Intercept) 0.0
#> year2 (Intercept) 247.2
#> Residual 480.4
#> Number of obs: 1916, groups: individ, 254; year2, 3
#> Fixed Effects:
#> (Intercept) sizea1 sizea2 sizea1:sizea2
#> 8.998e+01 3.119e-01 5.954e-01 -9.417e-05
#> fit warnings:
#> Some predictor variables are on very different scales: consider rescaling
#> optimizer (nloptwrap) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings
#>
#> ────────────────────────────────────────
#>
#> Reproductive status model:
#> [1] 1
#>
#> ────────────────────────────────────────
#>
#> Fecundity model:
#> Formula: feca2 ~ (1 | year2) + (1 | individ)
#> Zero inflation: ~sizea2 + (1 | year2) + (1 | individ)
#> Data: fec.data
#> AIC BIC logLik df.resid
#> 2889.505 2935.240 -1436.752 2238
#> Random-effects (co)variances:
#>
#> Conditional model:
#> Groups Name Std.Dev.
#> year2 (Intercept) 0.419688
#> individ (Intercept) 0.000388
#>
#> Zero-inflation model:
#> Groups Name Std.Dev.
#> year2 (Intercept) 2.577e-05
#> individ (Intercept) 1.020e+00
#>
#> Number of obs: 2246 / Conditional model: year2, 3; individ, 257 / Zero-inflation model: year2, 3; individ, 257
#>
#> Overdispersion parameter for nbinom2 family (): 0.233
#>
#> Fixed Effects:
#>
#> Conditional model:
#> (Intercept)
#> 1.514
#>
#> Zero-inflation model:
#> (Intercept) sizea2
#> 6.231072 -0.007315
#>
#> ────────────────────────────────────────────────────────────────────────────────
#> Juvenile survival model:
#> Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
#> Family: binomial ( logit )
#> Formula: alive3 ~ (1 | year2) + (1 | individ)
#> Data: juvsurv.data
#> AIC BIC logLik deviance df.resid
#> 323.6696 334.5847 -158.8348 317.6696 278
#> Random effects:
#> Groups Name Std.Dev.
#> individ (Intercept) 2.273e-08
#> year2 (Intercept) 0.000e+00
#> Number of obs: 281, groups: individ, 187; year2, 3
#> Fixed Effects:
#> (Intercept)
#> 1.084
#> optimizer (Nelder_Mead) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings
#>
#> ────────────────────────────────────────
#>
#> Juvenile observation model:
#> Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
#> Family: binomial ( logit )
#> Formula: obsstatus3 ~ (1 | year2) + (1 | individ)
#> Data: juvobs.data
#> AIC BIC logLik deviance df.resid
#> 91.4924 101.5338 -42.7462 85.4924 207
#> Random effects:
#> Groups Name Std.Dev.
#> individ (Intercept) 16.009
#> year2 (Intercept) 1.221
#> Number of obs: 210, groups: individ, 154; year2, 3
#> Fixed Effects:
#> (Intercept)
#> 10.39
#>
#> ────────────────────────────────────────
#>
#> Juvenile size model:
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: sizea3 ~ sizea2 + (1 | year2) + (1 | individ)
#> Data: juvsize.data
#> REML criterion at convergence: 1243.43
#> Random effects:
#> Groups Name Std.Dev.
#> individ (Intercept) 1.384
#> year2 (Intercept) 1.962
#> Residual 5.831
#> Number of obs: 193, groups: individ, 144; year2, 3
#> Fixed Effects:
#> (Intercept) sizea2
#> 3.0559 0.8482
#>
#> ────────────────────────────────────────
#>
#> Juvenile reproduction model:
#> [1] 1
#>
#>
#> ────────────────────────────────────────────────────────────────────────────────
#>
#> Number of models in survival table:4
#>
#> Number of models in observation table:5
#>
#> Number of models in size table:5
#>
#> Number of models in reproduction status table: 1
#>
#> Number of models in fecundity table:25
#>
#> Number of models in juvenile survival table:2
#>
#> Number of models in juvenile observation table:2
#>
#> Number of models in juvenile size table:2
#>
#> Number of models in juvenile reproduction table: 1
#>
#>
#> ────────────────────────────────────────────────────────────────────────────────
#>
#> General model parameter names (column 1), and specific names used in these models (column 2):
#> parameter_names mainparams
#> 1 time t year2
#> 2 individual individ
#> 3 patch patch
#> 4 alive in time t+1 surv3
#> 5 observed in time t+1 obs3
#> 6 size in time t+1 size3
#> 7 reproductive status in time t+1 repst3
#> 8 fecundity in time t+1 fec3
#> 9 fecundity in time t fec2
#> 10 size in time t size2
#> 11 size in time t-1 size1
#> 12 reproductive status in time t repst2
#> 13 reprodutive status in time t-1 repst1
#> 14 age in time t age
#> 15 individual covariate a in time t indcova2
#> 16 individual covariate a in time t-1 indcova1
#> 17 individual covariate b in time t indcovb2
#> 18 individual covariate b in time t-1 indcovb1
#> 19 individual covariate c in time t indcovc2
#> 20 individual covariate c in time t-1 indcovc1
#>
#>
#> ────────────────────────────────────────────────────────────────────────────────
#>
#> Quality control:
#>
#> Survival estimated with 257 individuals and 2246 individual transitions.
#> Observation estimated with 254 individuals and 2121 individual transitions.
#> Size estimated with 254 individuals and 1916 individual transitions.
#> Reproduction probability not estimated.
#> Fecundity estimated with 257 individuals and 2246 individual transitions.
#> Juvenile survival estimated with 187 individuals and 281 individual transitions.
#> Juvenile observation estimated with 154 individuals and 210 individual transitions.
#> Juvenile size estimated with 144 individuals and 193 individual transitions.
#> Juvenile reproduction probability not estimated.
#> NULL
We see here, as before, that size in time t-1 exerts an influence on some vital rates, including survival to time t+1 and size in time t+1. So, the historical IPM is the correct choice here. However, we will also create an ahistorical IPM for comparison. For that purpose, we will create the ahistorical linear model set.
<- modelsearch(lathvertipm, historical = FALSE,
lathmodels2ipm approach = "mixed", suite = "size",
vitalrates = c("surv", "obs", "size", "fec"), juvestimate = "Sdl",
bestfit = "AICc&k", sizedist = "gaussian", fecdist = "negbin",
fec.zero = TRUE, indiv = "individ", year = "year2", year.as.random = TRUE,
juvsize = TRUE, show.model.tables = TRUE, quiet = TRUE)
#> boundary (singular) fit: see ?isSingular
#> boundary (singular) fit: see ?isSingular
#> boundary (singular) fit: see ?isSingular
#> Warning in Matrix::sparseMatrix(dims = c(0, 0), i = integer(0), j = integer(0), : 'giveCsparse' has been deprecated; setting 'repr = "T"'
#> for you
#> Warning in Matrix::sparseMatrix(dims = c(0, 0), i = integer(0), j = integer(0), : 'giveCsparse' has been deprecated; setting 'repr = "T"'
#> for you
#> Warning in Matrix::sparseMatrix(dims = c(0, 0), i = integer(0), j = integer(0), : 'giveCsparse' has been deprecated; setting 'repr = "T"'
#> for you
#> boundary (singular) fit: see ?isSingular
#> boundary (singular) fit: see ?isSingular
Type summary(lathmodels2ipm)
to examine and compare against the historical case. We note some strong similarities here, although obviously size in time t-1 is no longer present in any vital rate model. Let’s move on now to the matrices themselves.
We will now create the historical suite of matrices covering the years of study. Be aware that the output matrices will be extremely large - large enough that some computers might have difficulty with them. If you encounter an error message telling you that you have run out of memory, then please try this on a more powerful computer :) .
<- flefko3(stageframe = lathframeipm, modelsuite = lathmodels3ipm,
lathmat3ipm supplement = lathsupp3, data = lathvertipm, year.as.random = FALSE,
patch.as.random = FALSE, reduce = FALSE)
summary(lathmat3ipm)
#>
#> This historical lefkoMat object contains 3 matrices.
#>
#> Each matrix is a square matrix with 10609 rows and columns, and a total of 112550881 elements.
#> A total of 3122121 survival transitions were estimated, with 1040707 per matrix.
#> A total of 61800 fecundity transitions were estimated, with 20600 per matrix.
#>
#> Vital rate modeling quality control:
#>
#> Survival estimated with 257 individuals and 2246 individual transitions.
#> Observation estimated with 254 individuals and 2121 individual transitions.
#> Size estimated with 254 individuals and 1916 individual transitions.
#> Reproduction probability not estimated.
#> Fecundity estimated with 257 individuals and 2246 individual transitions.
#> Juvenile survival estimated with 187 individuals and 281 individual transitions.
#> Juvenile observation estimated with 154 individuals and 210 individual transitions.
#> Juvenile size estimated with 144 individuals and 193 individual transitions.
#> Juvenile reproduction probability not estimated.
#> NULL
These are giant matrices. With 10,609 rows and columns, there are a total of 112,550,881 elements per matrix. But they are also amazingly sparse - with 1,061,307 elements estimated, 0.9% of elements per matrix are non-zero.
Let’s now build the ahistorical IPMs.
<- flefko2(stageframe = lathframeipm, modelsuite = lathmodels2ipm,
lathmat2ipm supplement = lathsupp2, data = lathvertipm, year.as.random = FALSE,
patch.as.random = FALSE, reduce = FALSE)
summary(lathmat2ipm)
#>
#> This ahistorical lefkoMat object contains 3 matrices.
#>
#> Each matrix is a square matrix with 103 rows and columns, and a total of 10609 elements.
#> A total of 30621 survival transitions were estimated, with 10207 per matrix.
#> A total of 600 fecundity transitions were estimated, with 200 per matrix.
#>
#> Vital rate modeling quality control:
#>
#> Survival estimated with 257 individuals and 2246 individual transitions.
#> Observation estimated with 254 individuals and 2121 individual transitions.
#> Size estimated with 254 individuals and 1916 individual transitions.
#> Reproduction probability not estimated.
#> Fecundity estimated with 257 individuals and 2246 individual transitions.
#> Juvenile survival estimated with 187 individuals and 281 individual transitions.
#> Juvenile observation estimated with 154 individuals and 210 individual transitions.
#> Juvenile size estimated with 144 individuals and 193 individual transitions.
#> Juvenile reproduction probability not estimated.
#> NULL
The ahistorical IPMs are certainly smaller than the historical IPMs, but are nonetheless huge in comparison to the matrices estimated in previous analyses. Although huge, these matrices are not sparse - 10,407 elements out of 10,609 per matrix are estimated (98.1%). Fortunately, we can assume that neither IPM is overparameterized, since ultimately the elements in an IPM and any other function-based matrix reflect the statistical power of the underlying vital rate models. In lefko3
, the vital rate models used are the best-fit models from exhaustive model selection, and so are already the most parsimonious from within the suite of tested models.
Let’s take a look at the top-left corner of the first ahistorical matrix (the matrix is too huge to inspect in full here).
print(lathmat2ipm$A[[1]][1:25,1:5], digits = 3)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.345 0.00e+00 0.00000 0.34412 0.34352
#> [2,] 0.054 0.00e+00 0.00000 0.16252 0.16252
#> [3,] 0.000 4.82e-05 0.08933 0.08962 0.09017
#> [4,] 0.000 4.68e-07 0.04247 0.04173 0.04007
#> [5,] 0.000 5.09e-69 0.04476 0.04426 0.04303
#> [6,] 0.000 2.38e-195 0.04625 0.04602 0.04530
#> [7,] 0.000 0.00e+00 0.04685 0.04692 0.04675
#> [8,] 0.000 0.00e+00 0.04653 0.04689 0.04730
#> [9,] 0.000 0.00e+00 0.04531 0.04595 0.04692
#> [10,] 0.000 0.00e+00 0.04325 0.04414 0.04564
#> [11,] 0.000 0.00e+00 0.04048 0.04157 0.04351
#> [12,] 0.000 0.00e+00 0.03715 0.03839 0.04068
#> [13,] 0.000 0.00e+00 0.03342 0.03475 0.03728
#> [14,] 0.000 0.00e+00 0.02947 0.03085 0.03350
#> [15,] 0.000 0.00e+00 0.02548 0.02684 0.02951
#> [16,] 0.000 0.00e+00 0.02160 0.02290 0.02549
#> [17,] 0.000 0.00e+00 0.01796 0.01915 0.02158
#> [18,] 0.000 0.00e+00 0.01463 0.01571 0.01792
#> [19,] 0.000 0.00e+00 0.01169 0.01263 0.01458
#> [20,] 0.000 0.00e+00 0.00915 0.00995 0.01163
#> [21,] 0.000 0.00e+00 0.00703 0.00769 0.00910
#> [22,] 0.000 0.00e+00 0.00529 0.00583 0.00698
#> [23,] 0.000 0.00e+00 0.00391 0.00433 0.00525
#> [24,] 0.000 0.00e+00 0.00283 0.00315 0.00387
#> [25,] 0.000 0.00e+00 0.00201 0.00225 0.00280
This matrix is very large, of course, so is difficult to read properly. We can get another handle on quality control by checking the column sums of the first U matrix, to make sure that all column sums look like survival probabilities.
summary(colSums(lathmat2ipm$U[[1]]))
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.0000487 0.9838110 0.9987809 0.9540850 0.9998662 0.9999848
Everything looks OK, with stage survival probabilities within the realm of possibility.
Let’s now repeat with the historical matrices. First the top corner of the first historical matrix.
print(lathmat3ipm$A[[1]][1:25,1:10], digits = 3)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0.345 0 0 0 0 0 0 0 0 0
#> [2,] 0.000 0 0 0 0 0 0 0 0 0
#> [3,] 0.000 0 0 0 0 0 0 0 0 0
#> [4,] 0.000 0 0 0 0 0 0 0 0 0
#> [5,] 0.000 0 0 0 0 0 0 0 0 0
#> [6,] 0.000 0 0 0 0 0 0 0 0 0
#> [7,] 0.000 0 0 0 0 0 0 0 0 0
#> [8,] 0.000 0 0 0 0 0 0 0 0 0
#> [9,] 0.000 0 0 0 0 0 0 0 0 0
#> [10,] 0.000 0 0 0 0 0 0 0 0 0
#> [11,] 0.000 0 0 0 0 0 0 0 0 0
#> [12,] 0.000 0 0 0 0 0 0 0 0 0
#> [13,] 0.000 0 0 0 0 0 0 0 0 0
#> [14,] 0.000 0 0 0 0 0 0 0 0 0
#> [15,] 0.000 0 0 0 0 0 0 0 0 0
#> [16,] 0.000 0 0 0 0 0 0 0 0 0
#> [17,] 0.000 0 0 0 0 0 0 0 0 0
#> [18,] 0.000 0 0 0 0 0 0 0 0 0
#> [19,] 0.000 0 0 0 0 0 0 0 0 0
#> [20,] 0.000 0 0 0 0 0 0 0 0 0
#> [21,] 0.000 0 0 0 0 0 0 0 0 0
#> [22,] 0.000 0 0 0 0 0 0 0 0 0
#> [23,] 0.000 0 0 0 0 0 0 0 0 0
#> [24,] 0.000 0 0 0 0 0 0 0 0 0
#> [25,] 0.000 0 0 0 0 0 0 0 0 0
The sparseness of the matrix means that the vast majority of it will be composed of 0s. Let’s take a look at a summary of the column sums of the first survival-transition matrix.
summary(colSums(lathmat3ipm$U[[1]]))
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.0000 0.9963 0.9999 0.9690 1.0000 1.0000
These numbers also all look fine. These are the expected survival probabilities to time t+1 of individuals in each combination of stages in times t-1 and t.
Let’s do a further comparison - let’s view a matrix plot of each kind of MPM, ahistorical and then historical.
::image2(lathmat2ipm$A[[1]], col = c("white", rev(heat.colors(500)), "black"), border = "black", text.col = NA)
popbiotitle("Ahistorical")
Figure 6.4. Images of historical vs. historical matrices
::image(SparseM::as.matrix.csr(lathmat3ipm$A[[1]]))
SparseMtitle("Historical")
Figure 6.4. Images of historical vs. historical matrices
The plots above show the major differences between ahistorical and historical MPMs. The ahistorical matrix is large but dense, mostly full of non-zero entries. In contrast, the historical matrix is huge and sparse, mostly full of zeroes with a general pattern to the distribution of non-zero elements. It should be obvious that many methodologies used for ahistorical analysis need to change to deal with the reality of the historical MPM as a series of huge, sparse matrices. Fortunately, package lefko3
includes these methodologies.
Now let’s estimate the mean IPM matrices. This code will estimate 1 mean matrix each, because we did not separate patches in the data reorganization and vital rate modeling.
<- lmean(lathmat2ipm)
lath2ipmmean summary(lath2ipmmean)
#>
#> This ahistorical lefkoMat object contains 1 matrix.
#>
#> Each matrix is a square matrix with 103 rows and columns, and a total of 10609 elements.
#> A total of 10207 survival transitions were estimated, with 10207 per matrix.
#> A total of 200 fecundity transitions were estimated, with 200 per matrix.
#> NULL
<- lmean(lathmat3ipm)
lath3ipmmean summary(lath3ipmmean)
#>
#> This historical lefkoMat object contains 1 matrix.
#>
#> Each matrix is a square matrix with 10609 rows and columns, and a total of 112550881 elements.
#> A total of 1040707 survival transitions were estimated, with 1040707 per matrix.
#> A total of 20600 fecundity transitions were estimated, with 20600 per matrix.
#> NULL
As a check, let’s take a look at the column sums of the grand mean survival-transition matrix from each case.
writeLines("\nAhistorical matrix stage survival distribution: ")
#>
#> Ahistorical matrix stage survival distribution:
summary(colSums(lath2ipmmean$U[[1]]))
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.0000404 0.9765161 0.9987748 0.9451579 0.9998662 0.9999849
writeLines("\nHistorical matrix stage-pair survival distribution: ")
#>
#> Historical matrix stage-pair survival distribution:
summary(colSums(lath3ipmmean$U[[1]]))
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.0000 0.9887 0.9994 0.9603 1.0000 1.0000
All looks fine! Let’s also take a look at a portion of one of the conditional historical matrices, particularly the matrix conditional on vegetative dormancy in time t-1. This matrix can be compared to the ahistorical mean to assess the impacts of history on the matrix elements themselves.
<- cond_hmpm(lath3ipmmean)
l3mcond print(l3mcond$Acond[[1]]$Dorm[1:20,1:8], digits = 3)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,] 0 0 0.00000 0.34412 0.34352 0.34251 0.34084 0.3381
#> [2,] 0 0 0.00000 0.26588 0.26588 0.26588 0.26588 0.2659
#> [3,] 0 0 0.08878 0.08878 0.08878 0.08878 0.08878 0.0888
#> [4,] 0 0 0.04453 0.04425 0.04350 0.04249 0.04125 0.0398
#> [5,] 0 0 0.04492 0.04488 0.04460 0.04404 0.04320 0.0421
#> [6,] 0 0 0.04449 0.04471 0.04491 0.04482 0.04445 0.0438
#> [7,] 0 0 0.04327 0.04372 0.04441 0.04480 0.04492 0.0447
#> [8,] 0 0 0.04130 0.04198 0.04311 0.04397 0.04457 0.0449
#> [9,] 0 0 0.03870 0.03956 0.04107 0.04237 0.04341 0.0442
#> [10,] 0 0 0.03557 0.03658 0.03841 0.04007 0.04151 0.0427
#> [11,] 0 0 0.03208 0.03318 0.03524 0.03718 0.03896 0.0406
#> [12,] 0 0 0.02838 0.02953 0.03173 0.03385 0.03588 0.0378
#> [13,] 0 0 0.02462 0.02577 0.02801 0.03024 0.03242 0.0345
#> [14,] 0 0 0.02095 0.02206 0.02426 0.02649 0.02873 0.0309
#> [15,] 0 0 0.01747 0.01851 0.02059 0.02276 0.02497 0.0272
#> [16,] 0 0 0.01428 0.01522 0.01714 0.01917 0.02128 0.0235
#> [17,] 0 0 0.01144 0.01227 0.01398 0.01582 0.01778 0.0198
#> [18,] 0 0 0.00898 0.00969 0.01118 0.01281 0.01456 0.0164
#> [19,] 0 0 0.00691 0.00750 0.00876 0.01015 0.01169 0.0134
#> [20,] 0 0 0.00521 0.00569 0.00672 0.00789 0.00919 0.0106
Now let’s estimate the deterministic population growth rates and plot them.
<- lambda3(lathmat2ipm)
ipm2lambda <- lambda3(lathmat3ipm)
ipm3lambda
#meanlambda2 <- lambda3(lath2ipmmean)
#meanlambda3 <- lambda3(lath3ipmmean)
plot(lambda ~ year2, data = ipm2lambda, xlab = "Year", ylab = "Lambda",
ylim = c(0.65, 1.00), type = "l", lwd = 2, bty = "n")
lines(lambda ~ year2, data = ipm3lambda, lwd = 2, lty = 2, col = "red")
legend("bottomleft", c("ahistorical", "historical"), lty = c(1, 2),
col = c("black", "red"), lwd = 2, bty = "n")
Figure 6.5. Ahistorical vs. historical lambda
Ahistorical estimates of \(\lambda\) are lower than historical estimates, and the historical \(\lambda\) values are more in line with estimates from the other Lathyrus vignettes.
Let’s now take a peek at the stochastic growth rate, \(a = \text{log} \lambda _{S}\). We will set the number of simulations low in the historical case in order to keep the amount of memory used and computational time low, because the size of the historical matrices will use up plenty of both. Normally we would want to keep the number of simulations at least at the default level, which is 10,000.
slambda3(lathmat2ipm)
#> pop patch a var sd se
#> 1 1 1 -0.2103745 0.01043859 0.1021694 0.001021694
slambda3(lathmat3ipm, times = 1000)
#> pop patch a var sd se
#> 1 1 1 -0.1376136 0.00746988 0.08642847 0.002733108
The historical growth rate is larger than the ahistorical, as in the deterministic case, although both sets of numbers suggest a decreasing population over time.
Now let’s compare the stable stage distribution from both the ahistorical and historical mean MPMs.
<- stablestage3(lath2ipmmean)
ipm2ss <- stablestage3(lath3ipmmean)
ipm3ss
<- cbind.data.frame(ipm2ss$ss_prop, ipm3ss$ahist$ss_prop)
ss_put_together names(ss_put_together) <- c("ahist", "hist")
rownames(ss_put_together) <- ipm2ss$stage_id
barplot(t(ss_put_together), beside=T, ylab = "Proportion", xlab = "Stage",
col = c("black", "red"), bty = "n")
legend("topright", c("ahistorical", "historical"), col = c("black", "red"),
pch = 15, bty = "n")
Figure 6.6. Ahistorical vs. historically-corrected stable stage distribution
Both ahistorical and historical approaches show the stable stage distribution dominated by the first stage, which is the dormant seed stage. The importance of the seed bank to the population is quite clear in this analysis! However, the historical analysis suggests a stronger weighting of larger adults, with the distribution moving rightward slightly.
Next, we will estimate the reproductive values associated with the element-wise mean matrices.
<- repvalue3(lath2ipmmean)
ipm2rv <- repvalue3(lath3ipmmean)
ipm3rv
<- cbind.data.frame(ipm2rv$rep_value, ipm3rv$ahist$rep_value)
rv_put_together names(rv_put_together) <- c("ahist", "hist")
$ahist <- rv_put_together$ahist / max(rv_put_together$ahist)
rv_put_together$hist <- rv_put_together$hist / max(rv_put_together$hist)
rv_put_togetherrownames(rv_put_together) <- ipm2rv$stage_id
barplot(t(rv_put_together), beside=T, ylab = "Relative rep value",
xlab = "Stage", col = c("black", "red"), bty = "n")
legend("topleft", c("ahistorical", "historical"), col = c("black", "red"),
pch = 15, bty = "n")
Figure 6.7. Ahistorical vs. historically-corrected reproductive values
A quick scan through these values shows that the highest reproductive values in the ahistorical analysis are for the largest adults. Since these values have been scaled to the contribution of dormant seed, the reproductive values suggest the important contribution of large adults to the maintenance of the population. However, historically-corrected reproductive values drop off once adults get mildly large, with the largest value associated with plants with a leaf volume of 5076 (the maximum is >7000).
Given the size of these matrices and the difficulty of working with them, we will skip sensitivity analysis here and move on to elasticity analysis.
<- elasticity3(lath2ipmmean)
lath2ipmelas <- elasticity3(lath3ipmmean)
lath3ipmelas
writeLines("\nThe highest ahistorical elasticity is associated with element: ")
#>
#> The highest ahistorical elasticity is associated with element:
which(lath2ipmelas$ah_elasmats[[1]] == max(lath2ipmelas$ah_elasmats[[1]]))
#> [1] 209
writeLines("\nThe highest historically-corrected elasticity is associated with element: ")
#>
#> The highest historically-corrected elasticity is associated with element:
which(lath3ipmelas$ah_elasmats[[1]] == max(lath3ipmelas$ah_elasmats[[1]]))
#> [1] 209
Both analyses agree that \(\lambda\) is most elastic in response to stasis in vegetative dormancy. Now let’s plot the elasticity of \(\lambda\) to transitions from both perspectives.
<- cbind.data.frame(colSums(lath2ipmelas$ah_elasmats[[1]]),
elas_put_together colSums(lath3ipmelas$ah_elasmats[[1]]))
names(elas_put_together) <- c("ahist", "hist")
rownames(elas_put_together) <- lath2ipmelas$stages$stage_id
barplot(t(elas_put_together), beside=T, ylab = "Elasticity of lambda",
xlab = "Stage", col = c("black", "red"), bty = "n")
legend("topright", c("ahistorical", "historical"), col = c("black", "red"),
pch = 15, bty = "n")
Figure 6.8. Ahistorical vs. historically-corrected elasticity of lambda to stage
The plot of these distributions shows the strong importance of vegetative dormancy, which is the tallest bar in both plots (the first bars, corresponding to dormant seeds and seedlings, have elasticity at nearly 0). However, the distribution of elasticity values in adult stages is shifted to the right in the historically-corrected IPM. Thus, while the ahistorical IPM shows the second highest elasticity of \(\lambda\) to be associated with plants with a leaf volume of 746, historically-corrected analysis suggests that the second highest elasticity is associated with plants with a leaf volume of 960.
Now let’s take a look at the summed elasticities of different kinds of transitions, beginning with a comparison of ahistorical to historically-corrected transitions.
<- summary(lath2ipmelas)
lath2elas_sums <- summary(lath3ipmelas)
lath3elas_sums
<- cbind.data.frame(lath2elas_sums$ahist[,2], lath3elas_sums$ahist[,2])
elas_sums_together names(elas_sums_together) <- c("ahist", "hist")
rownames(elas_sums_together) <- lath2elas_sums$ahist$category
barplot(t(elas_sums_together), beside=T, ylab = "Elasticity of lambda", xlab = "Transition",
col = c("black", "red"), bty = "n")
legend("topright", c("ahistorical", "historical"), col = c("black", "red"), pch = 15, bty = "n")
Figure 6.9. Ahistorical vs. historically-corrected elasticity of lambda to transitions
We see extremely similar transition elasticities between ahistorical and historical analyses, with growth and shrinkage the most influential on \(\lambda\) while fecundity is by far the least influential.
Finally, let’s estimate the elasticity of stochastic lambda, \(a = \text{log} \lambda _{S}\), to matrix elements. We will only focus on the ahistorical case to save time and compare with the deterministic elasticity matrix. However, users can update the code below to estimate stochastic elasticities for the historical MPM, as well.
<- elasticity3(lathmat2ipm, stochastic = TRUE) lath2ipmelas_s
Users can assess the importance of temporal environmental stochasticity with this analysis in a variety of ways, for example by taking the difference between the deterministic and stochastic elasticity matrices, and seeing where the non-zero elements arise.
Further analytical tools are being planned for lefko3
, but packages that handle projection matrices can typically handle the individual matrices produced and saved in lefkoMat
objects in this package. Differences, obscure results, and errors sometimes arise when packages are not made to handle large and/or sparse matrices - historical matrices are both, and so care must be taken with their analysis.
We are grateful to two anonymous reviewers whose scrutiny improved the quality of this vignette. The project resulting in this package and this tutorial was funded by Grant-In-Aid 19H03298 from the Japan Society for the Promotion of Science.