Reading Notes: A Primer of Ecology with R (Ch 2)
The revenge of matrix algebra
In the last chapter of A Primer of Ecology With R, we looked at ecological processes with simple exponential growth—so called “density independent” growth. Chapter 2 looks at “density independent demography” (emphasis mine), which looks to understand more about the population than just its growth rate. Per Stevens: “Demography is the study of populations with special attention to age or stage structure” with “stage” being both the obvious (life stage) but also “useful categories of individuals” which would include things like sex and ancestry.
Stevens introduces the idea of a life cycle graph which can then be translated into a matrix called the “population projection matrix”.
It looks like the first row of the matrix relates to how things relate to the initial stage (seeds in this case). Since only one known organism ever regresses in their development1, this reflects the Fecundity of the subject at that life stage. P_{3,3} reflects the fact that fully grown adults tend to stay fully grown until they die.
The book then goes through how to use this matrix to forecast into the future. Basically, the proccess involves:
- Taking your current population projection matrix
- Identifying the numbers of members at each stage, stored as a vector.
- Using matrix multiplication to multiply the matrix \times the population vector.
- Saving this new value as the new vector of members at each stage.
Rinse and repeat however many times you want.
From here, you’re able to calculate annual population changes, which allows us to calculate r from Chapter 1.
Analyzing the Projection Matrix
The fact that we’ve contorted our knowledge into a matrix means we can abuse ourselves use all of the machinery of matrix algebra to learn some really interesting things!
For example: What if we wanted to summarize, in one clean(ish) number, what the projection matrix entails for the population? We can use eigenanlysis, which seeks to find a solution to the following:
\begin{align*}\bf{Aw} = \lambda\bf{w}\end{align*}
Where \bf{A} is your population projection matrix, \bf{w} is an eigenvector and \lambda is an eigenvalue.2 We’re not limited to \bf{A} being your projection matrix, though as we’ll see in a bit.
If \bf{A} is a diagonalizable3 n \times n matrix, there will be n independent eigen(value/vector) solutions with the largest eigenvalue being the “dominant” one. So, in practice, the above equation is more like:
\begin{align*} \bf{A} = \bf{Q\Lambda Q^{-1}} \end{align*}
Where Q is a matrix where column i is the ith eigenvector and \Lambda is a diagonal matrix of eigenvalues. (Thanks, Wikipedia!4) The dominant eigenvalue, \lambda_1 is “the finite rate of increase”—which I think is the same as \lambda from chapter 1?
To find the stable stage distribution, we can look to w_1, or the eigenvector associated with \lambda_1 and softmax it. This sort of seems to be taken as a given in this book and in other resources I quickly skimmed online. I’m assuming that this is due to the fact that the first eigenvalue is (typically) much larger than the remaining ones and, thus, it and its associated vector “explain” more of the system. But why it wins out probably merits some deeper investigations on my part…
If we pivot instead to the left eigenvalue (something I hadn’t even come into contact before in psychometrics!5) we get the “reproductive value”—which is how important each stage is to contributing to future reproduction. It took me some time to get some kind of intuition around this, but what helped was learning that the left eigenmatrix is the transpose of the right (\bf{Q}^{-1}) and is generated by doing a standard egienvalue analysis on the transpose of your original matrix. That transpose effectively makes it so you’re understanding the fitness of individuals looking backwards6.
Finally, this section introduces sensitivities and elasticities. Sensitivities are how much each stage transition contributes to the \lambda.
\begin{align*} \frac{\delta\lambda}{\delta a_{i,j}} = \frac{v_{i,j}w_{i,j}}{\bf{v \cdot w}} \end{align*}
Which is how much a very small change in the i,jth element in \bf{A} contributes to the (dominant) \lambda. Elastitcities are the same idea, but are weighted by the transition probability which allows us to look at things on a percentage level (similar to elasticities in economics). This weighting, to me, fixes up an otherwise annoying property of the sensitiviy matrix: impossible transitions have non-zero values in the sensitivity matrix but not in the elasticity matrix. Which makes sense! What happens when something becomes marginally less impossible? It’s still impossible!
One thing that would make this relevant to my work almost immediately is if this can be generalized to more complex transition states. For example, someone may be a non-visitor, an ocassional visitor, or an annual pass holder—each of these with transition states to each other. Some quick googling/gemini-ing7 suggests that this is a thing for network analysis, which makes sense! Look at that, this is professionally useful already!
Working with Real Data
The next section involves data wrangling. I truly hate to be that guy—but I’m going to leave that as an exercise for the reader. I don’t feel a strong urge to go through the exercise myself here since the data can take damn-near any shape on initial ingestion. More what I need to know is what I’m transforming the data to. And that’s already known—the transition matrix! What we need is longitudinal data on known individuals to be able to create it.
The big thing that this mentions is the use of bootstrapping to get a sense of how certain we are of the estimands. Since bootstrapping has come up in both chapters now, I’m getting the feeling that it’s a quite important method. Which makes sense—we often are dealing with very small numbers of observations in total. (It also makes sense why bayesian methods can be useful here, vis McElreath). Fortunately, Stevens suggests some resources on bootstrapping…which triggered an ADHD rabbithole that added 3 more stats books to my “to-read” pile. Oh well. There are definitely worse problems to have!
Footnotes
The fact that this is not zero is absolutely insane to me. We have actual pheonixes in our midst and they take the form of the immortal jellyfish↩︎
Hooray, I recognize these things! Thanks psychometrics! But, also, oh no! I recognize these things! Damn you psychometrics!↩︎
Don’t worry, virtually every real-world matrix you will deal with in statistics is diagonalizable.↩︎
Now I really owe Jimmy $3 next time the donation campaign rolls around.↩︎
This is probably because you deal pretty much exclusively with symmetrical matrices in that context—e.g., covariance and correlation matrices—meaning that the left and right eigenvectors are equivalent. So there was probably no real reason to differentiate between the two.↩︎
Full disclosure: I had gemini help me here to make sure I was understanding it properly. I had it point me to some resources that let me work on it a bit deeper. Which is good because my original intuition was wrong! These things can be used for pedagogy—but you’ve got to introduce some friction.↩︎
Not sure if that’ll ever take off as a verb—but who knows?!↩︎
Reuse
Citation
@online{licari2026,
author = {Licari, Peter},
title = {Reading {Notes:} {A} {Primer} of {Ecology} with {R} {(Ch} 2)},
date = {2026-06-17},
url = {https://www.peterlicari.com/posts/ecology_primer_r_ch2_26/},
langid = {en}
}