Several interesting analyses have used MPMs from many species to
explore life history strategies using principal components analysis
(PCA). A potential criticism of these studies is that the underlying
data are biased towards certain taxa, life histories, and biomes. It is
unclear how much this bias could influence observed patterns. It would
therefore be useful to simulate realistic MPMs to explore the potential
artefactual patterns that could emerge from biased data. Here I show how
mpmsim can help with this task and enable the exploration
of PCA space as an aid to understanding life history strategies.
Load the required packages
generate_mpm_set() to simulate 50 matrices
with the archetype 1 life history from Takada et al. (2018). This life
history archetype is one where transition from/to any stage is possible
and where individuals can progress and retrogress rapidly. The function
generate_mpm_set returns a
set.seed(42) constrain_df <- data.frame(fun = "lambda", arg = NA, lower = 0.9, upper = 1.1) sim_life_hist_1 <- generate_mpm_set( n = 50, n_stages = 3, fecundity = c(0, 6, 6), archetype = 1, split = TRUE, max_surv = 0.95, constraint = constrain_df ) #> Warning in cdb_build_cdb(mat_u = U_list, mat_f = F_list): Metadata does not include a `SpeciesAccepted` column, so number #> of species not provided when viewing object.
Some of these matrices will be reducible, which leads to analytical
problems with some calculations. These can be filtered out using
cdb_flag() followed by
For convenience, these matrices can be added to the
compadreDB object like this, and turned into a regular data
tibble) like this.
Before proceeding with the calculation of life history traits I make
a new function,
gt_lt, to calculate generation time from a
Now we can use a combination of
mapply to calculate the life history traits for each matrix
sim_life_hist_1$gt_lt <- mapply( gt_lt, sim_life_hist_1$matU, sim_life_hist_1$matF ) sim_life_hist_1$longevity <- sapply(sim_life_hist_1$matU, Rage::longevity, x_max = 1000, lx_crit = 0.01 ) sim_life_hist_1$lifeExpect <- sapply( sim_life_hist_1$matU, Rage::life_expect_mean ) sim_life_hist_1$entropy_d <- mapply( entropy_d, sim_life_hist_1$matU, sim_life_hist_1$matF ) sim_life_hist_1$entropy_k <- mapply(entropy_k, sim_life_hist_1$matU) sim_life_hist_1$nrr_R0 <- mapply( net_repro_rate, sim_life_hist_1$matU, sim_life_hist_1$matF )
Now we have added these variables to the data set we can extract them into a dataset for the PCA.
Then we can run the PCA, and add the first two principle components to the data frame for plotting purposes.
The plot can be made using
autoplot, from the
PCA_plot <- autoplot( object = PCA, alpha = 0, size = 4, fill = "#55616D60", loadings.colour = "#0072B2", shape = 16, loadings = TRUE, loadings.label = TRUE, loadings.label.colour = "red", loadings.label.size = 3, loadings.label.repel = TRUE, frame = FALSE, frame.type = "norm", scale = 0 ) PCA_plot$layers <- c( geom_point( aes_( x = pcData$PC1, y = pcData$PC2 ), size = 2, alpha = 0.5 ), PCA_plot$layers ) PCA_plot
The PCA loadings show two strong axes. One with evolutionary entropy, longevity, generation time and life expectancy aligned, and one with R0 on its own. Life table entropy is aligned more or less equally with both. This is a rather different pattern than can be observed with real data. Why?
If we repeat the whole analysis with a different archetype (4) we get the following plot.