Tutorials: Monte Carlo runs

Ecosim has a Monte Carlo (MC) facility  for evaluating input parameter uncertainty by resampling parameters to search for input parameter combinations that result in better fit to time series.

You can open scenarios and load time series by clicking the down-arrow next to the icons at the top of the EwE interface.

The routine requires a balanced model with time series, and we will here use the “Anchovy Bay true.ewemdb” model, with the “anch bay” scenario and the “anchovy bay true” time series, (download all along with an AIC spreadsheet from this link). Open the model, and load the scenario and time series. Then open the MC routine from Ecosim > Tools > Monte Carlo simulation. Check the Settings tab. If you check Retain better fitting estimates, the routine will resample parameters from a new better fit whenever such are obtained. This turns the routine into a Markov Chain Monte Carlo (MCMC) routine, which usually will make it possible and easier for the routine to find additional mass-balanced solutions.

On the B tab, set the CV to 0.4 for all groups (just click where it says CV in the top row, then enter 0.4 in the Apply box, return), and just leave the other parameters as is. Click Run trials.

Go to the Biomass plot tab. For each run (of the default 20), the routine samples the parameters until it finds a balanced model, (how many tries that takes is given in the Ecopath runs field), it then runs Ecosim, and estimates summed squared residuals (SS). If the SS is lower than the previous best, the model will (if Retain better fitting estimates is checked), resample the input parameters around the new set of parameters that gives the lower SS. If you select Apply best fit the routine will transfer the best set of input parameters to the Ecopath model. You should therefore take care not to overwrite your model, so, it really is best to work on a copy of your model.

We here use just 20 runs for the simulations; in a real analysis, you may well choose to use thousands.

If you want to get statistics for parameter ranges etc., then click the Save output > All results in one file option before doing the run. You can locate the saved file from the Menu > Tools > Options > File Management. There, click the folder symbol to the right of Monte Carlo trial results, and you’ll get to a folder with a file, MonteCarloTrials.csv, which has the results – in a cumbersome format that requires some manipulation to make sense of.  For this simple model with just 20 runs, there’s over 1100 lines in the CSV file as parameters are saved for each run.

If you instead use the Save File > Separate files per trial, the routine will make a folder for each run and then save (in this case) 76 files within each run folder. For instance, biomass annual.csv, which will have the biomass by functional group for each year in the run. To deal with such file complexity: use R (or similar) for analysis.

You can use MC with the EcoSampler plug-in to store the samples that the MC runs for further analysis. See the EcoSampler User’s Guide for further information.

Media Attributions

  • EwE interface shortcut for loading files, scenarios and time series

License

Icon for the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

Ecosystem Modelling with EwE Copyright © 2024 by Ecopath International Initiative is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book