Resources

Available here are listings of all MATLAB programs included as boxes in the text. There are some corrections in the zip file below (CORRECTIONS.m) to the programs as they appeared in print.

Download all the files in a .zip archive. (76k)

Box 2.1 - randdraw.m MATLAB code to simulate population trajectories using Equation 2.1, and drawing each year's annual growth rate from a list of observed rates.

Box 3.3 MATLAB code defining five functions used in calculating the extinction time cumulative distribution function and its confidence limits:extcdf.m, stdnormcdf.m, gammarv.m, betarv.m, and chi2rv.m. These functions are used by many other programs in subsequent chapters.

Box 3.4 - extprob.m MATLAB code to calculate extinction probabilities and bootstrap confidence intervals.

Box 4.1 - tbar_ceiling.m MATLAB code to plot the mean time to extinction for the ceiling model (Equation 4.1) as functions of the carrying capacity and initial population size.

Box 4.4 - theta_logistic.m MATLAB code to predict the probability of extinction using the theta logistic model (Equation 4.2).

Box 4.5 - demstoch.m A MATLAB program to simulate growth of a density-dependent population with both environmental and demographic stochasticity. It would be straightforward to hybridize this code with the program "theta_logistic" in Box 4.4 to compute the probability of extinction under both types of stochasticity.

Box 4.6 - ricker_corr.m MATLAB code to calculate the probability of quasi-extinction for the Ricker model with temporally autocorrelated environmental effects.

Box 4.7 - extremes.m. MATLAB code to calculate extinction risk in the presence of catastrophes and bonanzas.

Box 5.1 - correct_sigma2.m MATLAB code to correct a raw estimate of σ2 for sampling variation when census counts represent means from replicate samples.

Box 5.2 - dennisholmes.m MATLAB code defining the function "dennisholmes", which estimates µ and σ2 using the method of Holmes (2001).

Box 7.1 - eigenall.m MATLAB code defining the function "eigenall", which calculates eigenvalues and eigenvectors of the matrix A. This function is used by many other programs in Chapters 7, 8, 9, and 11.

Box 7.2 - box7_2.m Fragment of MATLAB code that uses the function "eigenall" defined in Box 7.1 to generate Equations 7.8, 7.9, and 7.11 using the semi-palmated sandpiper projection matrix in Equation 7.5.

Box 7.3 - iidenv.m MATLAB code to simulate growth of a structured population in an iid stochastic environment. This program calls on the data filehudmats.m.

Box 7.4 - stoc_log_lam.m MATLAB code to estimate log ls by simulation and by Tuljapurkar's approximation. This program calls on the data filehudmats.m.

Box 7.5 - simext.m MATLAB code to simulate the extinction time cumulative distribution function. This program calls on the data file hudmats.m.

Box 7.6 - box7_6.m Fragment of MATLAB code to calculate the extinction time CDF for mountain golden heather using Tuljapurkar's approximation (Equations 7.12 and 7.13) and Equation 3.5. This program calls on the data filehudmats.m.

Box 8.1 - white.m MATLAB code to use White's method to correct for sampling variation.

Box 8.2 - kendall.m MATLAB code to use Kendall's method to correct for sampling variation.

Box 8.3 - betaval.m A second MATLAB function to make beta-distributed random numbers (see Box 3.3 for a different method). "betaval" returns a beta-distributed value with the specified CDF value. The program BetaDemo is also included, showing the use of betaval. This function is used by many other programs in Chapters 8, 9, and 11.

Box 8.4 - lnorms.m A MATLAB m-file for the function lnorms, which returns random lognormal values. This function is used by many other programs in Chapters 8, 9, and 11.

Box 8.5 - stretchbetaval.m A MATLAB m-file defining the function stretchbetaval, which returns stretched beta-distributed values. Note that this program uses betaval, defined in Box 8.3. The program StBetaDemo shows the use ofstretchbetaval.m. This function is used by many other programs in Chapters 8, 9, and 11.

Box 8.6 - corrrates.m A simple example program to generate correlated random vital rates using an estimated correlation matrix between vital rates.

Box 8.7 - stnormfx.m A MATLAB file for the function stnormalfx, which provides a good standard normals (Abramowitz and Stegun 1964). This function is used by many other programs in Chapters 8, 9, and 11.

Box 8.8 - AnalyzeCorrs.m A MATLAB program going through steps needed to calculate a correlation matrix and look for the problems caused by sparse sampling or small numbers of observations, using correlations for the desert tortoise.

Box 8.9 - BetweenYrCorrNEW.m A program, BetweenYrCorrNEW.m, to demonstrate the simulation of within-year correlations, autocorrelations, and cross-correlation in vital rates. Note that this program has been modified and is now quite different from BetweenYrCorr.m as described in the book. Also, this box contains a function that is called by the program, onestep.m.

Box 8.10 - vitalsimNEW.m A program, vitalsimNEW.m, to calculate the extinction time CDF and the stochastic growth rate for Hudsonia, using simulations that include correlation, autocorrelation, and cross-correlation. Note that this program has been modified and is now quite different from VitalSim.m as described in the book. Also, this box contains a function that is called by the program, onestep.m, and two other files that it calls: hudcorrs.matand the matrix definition program hudmxdef.m.

Box 8.11 - multiresult.m A function to decide the fates of a set of individuals simultaneously, given a set multinomial probabilities of different outcomes (after Caswell 2001, pg. 459).

Box 8.12 - lynx.m MATLAB code to perform a density-dependent demographic PVA for the Iberian lynx.

Box 8.13 - salmon_dd.m A MATLAB program to simulate deterministic, density-dependent growth of a salmon population.

Box 9.1 - vitalsens.m A MATLAB program to find the sensitivities and elasticities of λ1to vital rates.

Box 9.2 - limitsens.m MATLAB code to simulate random matrices between user-defined limits.

Box 9.3 - secder.m A MATLAB function to calculate the second derivatives of deterministic growth rate (or first derivatives of sensitivities) owith respect to matrix elements (modified from Caswell 2001). This function is used to calculate stochastic sensitivities (see Box 9.4).

Box 9.4 - StochSens.m A MATLAB program to calculate the sensitivities and elasticities of stochastic growth rate (λs) to means, variances, and covariances of matrix elements. This program calls on the data file tortmxs.mat.

Box 9.5 - stochsenssim.m A MATLAB program that performs stochastic simulations to estimate the sensitivities and elasticities of stochastic growth rate (λs) and extinction probabilities to mean, variance, and covariance of matrix elements. This program calls on the data files tortbetas.mat andtortcorrmx.mat, as well as the matrix definition program maketortmx.m. The program also calls the function betaset.m.

Box 10.1 - joincount.m A MATLAB program to calculate join-count statistics for spatial correlations between binary data. This program calls on the data filedelug90s.txt.

Box 11.1 - logregB.m A MATLAB program to find the maximum likelihood parameter values for a logistic regression model of metapopulation dynamics. This program calls on the function in Box 11.2 - logregA.m, which does most of the actual calculations. This program calls on the data file delugA.txt.

Box 11.2 - logregA.m A MATLAB function that provides an estimate of the log-likelihood of a set of occupancy, extinction, and colonization data, given a set of parameters provided by the program in Box 11.1 - logregB.m.

Box 11.3 - logregextsim.m A program to simulate a logistic regression model for patch-based metapopulation dynamics. This program calls on the data filedelugA.txt.

Box 11.4 - MultisiteCount.m A stochastic simulation for a count-based multi-site PVA. This program is a modification of single-population matrix models developed in Chapter 8. This program calls on the matrix definition programrailmxdef.m.

Box 11.5 - DemoMetaSim.m A MATLAB program to perform demographic, multi-site simulations. Much of the machinery needed for this program is identical to that in the vital rate-based simulation models presented previously, and in this code we refer to pieces of vitalsim.m in Box 8.10 that need to be inserted to make a fully functional program. This program calls on the data file coryrates.mat and the matrix definition program makecorymx.m