Title: Vitense, K., M.A. Hanson, B.R. Herwig, K.D. Zimmer, J. Fieberg (2021). Data and R code supporting "A hidden Markov model for ecosystems exhibiting alternative stable states" Authors: Kelsey Vitense, University of Minnesota, viten003@umn.edu Mark A. Hanson, Minnesota Department of Natural Resources Brian R. Herwig, Minnesota Department of Natural Resources Kyle D. Zimmer, University of St. Thomas John Fieberg, University of Minnesota Description: This repository contains R code supporting the results reported in Vitense et al. (2021). This collection also contains shallow data collected in Minnesota from 2009-2011. Files: 1. HMM.Rproj = R project file that can be used to associate all files in its same directory to an R project. We recommend you unzip all files/folders to your desired working directory and use the R (R Core Team 2019) user interface, RStudio (RStudio Team 2019). Double-clicking on 'HMM.Rproj' will open up a new RStudio window, and the working directory will automatically be set to the folder where the project files and directories are located. The following URL contains more information on how to use a project in RStudio: https://support.rstudio.com/hc/en-us/articles/200526207-Using-Projects Data directory We sampled 123 lakes in Minnesota, USA once in July during each of three consecutive years, 2009-2011. We collected water samples for total phosphorus (TP), total nitrogen (TN), and chlorophyll a (chl a) at two stations in each lake-year, which were frozen until analysis. TP was analyzed by persulfate digestion and ascorbic acid colorimetry, and TN by persulfate oxidation and second derivative spectrophotometry. We collected samples for chl a by filtering water through GF/F filters, which were analyzed using acetone extraction and fluorometric analysis. We computed average chl a (μg/L), TP (μg/L), and TN (μg/L) values for each lake-year. We sampled ubmerged aquatic vegetation (SAV) at 15 stations spaced evenly along three transects in each lake by dragging a weighted plant rake across 3 m of lake bottom and weighing plant biomass (wet weight) collected on the rake (methods modified from Deppe & Lathrop (1992)). We computed average SAV biomass (kg) across the stations and proportion of vegetated stations for each lake-year. We measured lake maximum depth (m) either once (23 lakes) or yearly (100 lakes) by measuring depths along these same parallel transects. We determined fish presence-absence, biomass, and community composition each year using a combination of gears deployed overnight. We set three mini-fyke nets targeting minnows and juvenile fishes (6.5-mm bar mesh with 4 hoops, 1 throat, 7.62 m lead, and a 0.69 X 0.99 m rectangular frame opening into the trap) overnight in each lake’s littoral zone. We deployed one experimental gill net targeting larger-bodied fish species (2 m by 61 m multifilament net with 19.0, 25.0, 32.0, 38.0, and 51.0-mm bar meshes) along the deepest depth contour in lakes less than 2 m deep or along a 2 m contour in lakes with sufficient depth. All sampled fish were sorted by species and weighed in bulk. We summarized the data as presence-absence and total biomass of fish species belonging to each major feeding guild (planktivores, benthivores, and piscivores). 2. State.csv a. Lake = unique lake identifier b. Depth09, Depth10, Depth11 = Max lake depth (m) in years 2009, 2010, 2011, respectively. c. SAVperc09, SAVperc10, SAVperc11 = Proportion of vegetated stations in years 2009, 2010, 2011, respectively. d. SAVms09, SAVms10, SAVms11 = Average submerged aquatic vegetation (SAV) mass measured for each lake (kg) in years 2009, 2010, 2011, respectively. e. Chla09, Chla10, Chla11 = Average chl a measured for each lake (micrograms/liter) in years 2009, 2010, 2011, respectively. f. TP09, TP10, TP11 = Average total phosphorus (TP) measured for each lake (micrograms/liter) in years 2009, 2010, 2011, respectively. g. TN09, TN10, TN11 = Average total nitrogen (TN) measured for each lake (micrograms/liter) in years 2009, 2010, 2011, respectively. 3. Fish.csv a. lake = unique lake identifier b. PLANK09, PLANK10, PLANK11 = Total planktivore mass (g) in years 2009, 2010, 2011, respectively. c. BENTH09, BENTH10, BENTH11 = Total benthivore mass (g) in years 2009, 2010, 2011, respectively. d. PISC09, PISC10, PISC11 = Total piscivore mass (g) in years 2009, 2010, 2011, respectively. e. BULLHEAD09, BULLHEAD10, BULLHEAD11 = Total black bullhead mass (g) in years 2009, 2010, 2011, respectively. f. CARP09, CARP10, CARP11 = Total common carp mass (g) in years 2009, 2010, 2011, respectively. g. carpPresence09, carpPresence10, carpPresence11 = Presence/Absence of common carp (0=absent, 1=present) in years 2009, 2010, 2011, respectively. h. bullPresence09, bullPresence10, bullPresence11 = Presence/Absence of black bullhead (0=absent, 1=present) in years 2009, 2010, 2011, respectively. Code directory 4. HMM_ModelA_wTip.R = Code to fit the Model A in Supporting Information that includes tipping point estimation. This file was used to generate the model run used in the paper, saved as R object "Saved_Runs/HMM_ModelA_wTip_1mil_240thin.rds" (file #10). Line 143 reads in this model - comment this line out if generating a new model run. 5. HMM_Model1.R = Code to fit Model 1 that uses fixed tipping points estimated from Model A. This file was used to generate the model run used in the paper, saved as R object "Saved_Runs/HMM_Model1_500thou_120thin_tip43350.rds" (file #11). Line 148 reads in this model - comment this line out if generating a new model run. 6. HMM_Model2_KuoMallickBeta.R = Code to fit Model 2 that uses fixed tipping points estimated from Model A. This file was used to generate the model run used in the paper, saved as R object "Saved_Runs/HMM_Model2_KuoMallick_500thou_120thin.rds" (file #12). Line 286 reads in this model - comment this line out if generating a new model run. This code also generates Tables 1 and 2 (files #17-19). 7. HMM_Model2_KuoMallickBetaTOPMODEL.R = Code to fit the top model selected in Model 2 (file #6). This file was used to generate the model run used in the paper, saved as R object "Saved_Runs/HMM_Model2_KuoMallickTOPMODEL_500thou_120thin.rds " (file #13). Line 215 reads in this model - comment this line out if generating a new model run. 8. Figure2.R = Code to produce Figure 2 in Vitense et al. (2021) (file #15). 9. Figure3.R = Code to produce Figure 3 in Vitense et al. (2021) (file #16). Saved_Runs directory 10. HMM_ModelA_wTip_1mil_240thin.rds = Saved model run generated using code in HMM_ModelA_wTip.R (file #4). 11. HMM_Model1_500thou_120thin_tip43350.rds = Saved model run generated using code in HMM_Model1.R (file #5). 12. HMM_Model2_KuoMallick_500thou_120thin.rds = Saved model run generated using code in HMM_Model2_KuoMallickBeta.R (file #6). 13. HMM_Model2_KuoMallickTOPMODEL_500thou_120thin.rds = Saved model run generated using code in HMM_Model2_KuoMallickBetaTOPMODEL.R (file #7). Figures directory: 14. FIGURE1.png = Figure 1 from Vitense et al. (2021), created in PowerPoint. 15. FIGURE2.png = Figure 2 from Vitense et al. (2021), generated using Figure2.R (file #8). 16. FIGURE3.png = Figure 3 from Vitense et al. (2021), generated using Figure3.R (file #9). Tables directory: 17. Table1_TopModels.csv = Table 1 from Vitense et al. (2021), generated using HMM_Model2_KuoMallickBeta.R (file #6). 18. Table2_TopClearVars.csv = Half of Table 2 from Vitense et al. (2021), generated using HMM_Model2_KuoMallickBeta.R (file #6). 19. Table2_TopTurbidVars.csv = Half of Table 2 from Vitense et al. (2021), generated using HMM_Model2_KuoMallickBeta.R (file #6). License/Restriction Info: These data are protected under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States license. References: Deppe, E. R. and R.C. Lathrop (1992). A comparison of two rake sampling techniques for sampling aquatic macrophytes. Wisconsin Department of Natural Resources, Findings #32, PUBL-RS-732-92. R Core Team (2019). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL http://www.R-project.org/. RStudio Team (2019). RStudio: Integrated Development for R. RStudio, PBC, Boston, MA URL http://www.rstudio.com/. Vitense, K., M.A. Hanson, B.R. Herwig, K.D. Zimmer, J. Fieberg (2021). A hidden Markov model for ecosystems exhibiting alternative stable states. Journal of Applied Ecology.