# Tutorial: Fitting time series with true values

In a previous tutorial we fitted the Anchovy Bay model to a simple time series file, mainly in order to explore the time series fitting procedures of Ecosim in a simple manner. Here, we will expand on this, notably by evaluate fitting when considering fisheries, food web, and environmental conditions, i.e. we add an environmental forcing function.

The present tutorial is a test to see how well Ecosim can fit a model with known parameters. The time series ‘data’ for this tutorial were thus derived from a model run with known primary production forcing and with known vulnerability multipliers. Can we retrieve those values?

Open the model *Anchovy Bay true.ewemdb* (download); then load the *anch bay* scenario, and then the *anchovybay true time* series, (which is also available in the *anchovybay true.csv* time series file).

Reset the vulnerability multipliers to the default: *Ecosim > Input > Vulnerabilities*. Click the upper left cell in the spreadsheet (above 1 and to the left of Prey\predator), to select the entire sheet, then enter the value 2 in *Set:* at the upper right, and click *Apply* to the right.

Run the model, *Ecosim > Output > Run Ecosim > Run* button. Check the output, notably on the Ecosim Group plots. As an example of what to look for, examine the cod screen. The model shows bigger decline in biomass than the data. What does that tell us about the vulnerability multiplier for cod?

Check the *Ecosim > Input > Forcing* function form where you should find two forcing functions, *1: True PP*, (which we will use later for comparisons), and *2: Fitting*, (which we will use for fitting). Check the *Ecosim > Input > Forcing function > Apply FF* (producer) form. Here there should be an *F2* in the (single not blocked entry field) for Phytoplankton (if not, then click the empty field and select the FF. The two forcing functions are, by the way, included in the time series file, and when/if you read it in, you’ll have to specify that you do not want to read in each of these as monthly values.

Now go *Ecosim > Tools > Fit* to time series. Try running a number of different fits; first with vulnerability search only. E.g., search groups with time series, and search for vulnerability multipliers for the seven groups with time series. Note what the ‘base’ SS is, and what you get with seven estimated parameters, probably a substantial reduction in SS. Try also to estimate fewer vulnerability multipliers. Also search for most sensitive parameters, and try with different number of parameters. Which groups are most/least sensitive? Are there any implications to be deducted from this? Notably consider if we are likely to have or get time series for the more sensitive groups.

For each run it is always a good practice to check the vulnerability form to see the estimated multipliers.

Also compare vulnerability multiplier fitting with searches by predator and by predator/prey combinations. As a rule, we find that searches by predator are most efficient – and easier to explain.

Reset the vulnerability multipliers. Now search for a primary production anomaly; check the *Anomaly search* on the Fit to time series form, and uncheck the *Vulnerability search*, so only search for an environmental signal. Before each run go to Ecosim, Input data, Forcing functions, and reset the shape of the Fitting forcing function. Try with different number of spline points, e.g., 2, 3, 4, 6, 10, and finally 0 (i.e. annual PP). Do you see clear environmental signals? Evaluate not just SS, but also if the anomalies are plausible (there can be a tendency to cut off or wildly increase PP at the beginning or end of time series as this often can be done without time series ‘penalty’). Based on this, select one or several number of spline points to test for the combined Vulnerability and Anomaly search – try such runs.

When you’ve done runs to fit, copy the results from the table on the Fit to time series form to a spreadsheet (so you don’t lose them). Evaluate AIC_{c} values, and consider implications for model selection.

- Consider how well the fitting routine is able to find the PP anomalies and vulnerabilities.
- Discuss the findings and their implications.

**Optional**

There is an additional time series in the model database, “anchovybay true partial”. It is similar to the previous, but omits a number of early time series values that help identify the cycling pattern. Try this time series to consider the effect of having time series with contrast.

**Vulnerability multipliers for the Anchovy Bay model **

Your model version may be a bit changed from what’s below, but should be close

1 | Whales | 1.14 |

2 | Seals | 2.38 |

3 | Cod | 1.28 |

4 | Whiting | 6.17 |

5 | Mackerel juv | 1.10 |

6 | Mackerel ad | 1.60 |

7 | Anchovy | 1.21 |

8 | Shrimp | >1000 |

9 | Benthos | 3.22 |

10 | Zooplankton | 2.26 |