DOI: 10.6084/m9.figshare.3568428
title: Supplement 1. MATLAB code used in simulations and analysis.

description: File List pacSalmonIterator.m extendVectorToLength.m get_ts_stats.m salmon_ts_SR_comparison.m short_forcing_scenarios.m pacSalmonIterator_single_figures.m read_agedistribution_data_Bristol.m read_agedistribution_data_Fraser.m salmon_ts_diagnostics.m <b> </b> BristolBay_Agedist_Jan2010.mat Fraser_AgeDist_May2010.mat ageStructuredSRSim.m ageStructuredSREq.m checkPersist.m BevertonHolt.m pacSalmonF.m pacSalmonF_fixed.m semelparousFluctuatingLogSurvival.m semelparousFluctuatingLogSurvival_fixed.m Ricker.m wavelet.m chisquare_inv.m chisquare_solve.m coif.m contwt.m invcwt.m wave_bases.m wave_signif.m xcorr_simple.m Description The Matlab script pacSalmonIterator.m is a wrapper that defines parameters and runs the simulations. All of the simulation functions are in the directory ageStructuredSimulator, which must be a sub-directory to the working directory where pacSalmonIterator.m resides. The range of forcing values and all other parameters used in the paper are given in the manuscript. The mean age at spawning was 4 years, corresponding to Fraser R. stocks. <i>Other files used in simulations, extracting data, etc.</i> The Matlab script extendVectorToLength.m is a helper file when assembling the age-structured population. The Matlab script get_ts_stats.m calculates time series metrics. Given a time series and wavelet, this will calculate: CV_PowerDom_Scale - A measure of cyclic consistency, called 'C' in the ms Mean_maxmin_ratio - A measure of cyclic dominance. Called 'D' in the ms The Matlab script salmon_ts_SR_comparison.m compares time series statistics to position on stock-recruit curve for actual sockeye data (Fig. 6 in the ms). The Matlab script short_forcing_scenarios.m creates the parameters needed to run some short, non-stochastic forcings of different types to see how/if they set up cycles (Fig. 5 in the ms). The Matlab script pacSalmonIterator_single_figures.m runs the simulations specified by short_forcing_scenarios.m and plots the results. The Matlab script read_agedistribution_data_Bristol.m reads in Bristol Bay data and formats it. The Matlab script read_agedistribution_data_Fraser.m reads in Fraser River data and formats it. The Matlab script salmon_ts_diagnostics.m calculates time series metrics for actual sockeye data by calling get_ts_stats.m. <i>Data Files:</i> The Matlab data file BristolBay_Agedist_Jan2010.mat contains age structure data as of Jan 2010 from Randall Peterman. The Matlab data file Fraser_AgeDist_May2010.mat containes age structure data as of May 2010 from Mike LaPointe. <i>Files in ageStructuredSimulator:</i> The Matlab script ageStructuredSRSim.m models the age-structured population dynamics. This is the code that was used for most of the simulations in the paper. This code requires inputting various function handles to define the fecundity and survival functions. These are explained in the text of the m-file. In addition to running the simulations, this file calls wavelet.m to perform wavelet analysis. The Matlab script ageStructuredSREq.m calculates the equilibrium of an age-structured model with density-dependent recruitment. A simplified version of ageStructuredSRSim.m The Matlab script checkPersist.m determines whether a given parameter set has a nonzero equilibrium (i.e., deterministic persistence). <i>Functions that define the demography of the species being modeled</i> These functions are specified as function handles (@function) when calling ageStructuredSRSim.m in pacSalmonIterator.m The Matlab script BevertonHolt.m calculates a stock-recruit curve, given parameters. The Matlab script pacSalmonF.m specifies a fecundity function for salmon. It returns the probability of spawning at each age, not fecundity per se. The Matlab script pacSalmonF_fixed.m specifies a fecundity function, just like pacSalmonF.m. This one allows for user-specified variation at specific times, rather than stochastic variation. The Matlab script semelparousFluctuatingLogSurvival.m calculates survival of an iteroparous species, which varies on the log scale. So S = exp(log(S)+sigma), where sigma is random normal error. The Matlab script semelparousFluctuatingLogSurvival_fixed.m is just like semelparousFluctuatingLogSurvival.m, but allows user-specified variation at specific times, rather than stochastic variation. The Matlab script Ricker.m calculates a stock-recruit curve, given parameters. The Matlab script wavelet.m calculates the wavelet spectrum. Originally written by Terrence and Compo, with some minor modifications. One key modification is to calculate the lag-1 autocorrelation directly from the data set (this is done in ageStructuredSRSim.m) rather than just use the default value, which seems to be from the NINO3 data set. The wavelet.m code uses a number of helper files: chisquare_inv.m chisquare_solve.m coif.m contwt.m invcwt.m wave_bases.m wave_signif.m xcorr_simple.m (if you don't have the signal processing toolbox, this calculates the cross-correlation for you)