Prepare your survey data
View source ↗On this page
On this page you turn your survey observations into an input bundle x that run_acl(x) and run_alscl(x) accept, and you check it before the first fit. You need the package installed (Install ALSCL), your survey numbers at length by year or quarter, mean weight and maturity at length, and the biological values of your stock listed in step 4.
| Step | What you will have afterwards |
|---|---|
| 1. Lay out three tables | A workbook or three CSV files with identical rows and columns |
| 2. Choose the time step | A time grid without hidden gaps and a decision about zeros |
| 3. Read the files | The three tables as a list in R, already checked for alignment |
| 4. Add the biology | The input bundle x with your stock's settings |
| 5. Check the bundle | A confirmation that x can be fitted, and the list of parameters that will be estimated |
1. Lay out three matching tables
Both models read three tables with the same layout: the survey index table data.CatL (numbers of fish caught by the survey in each length bin and time step), the weight table data.wgt (mean weight of one fish in each bin and time step) and the maturity table data.mat (proportion mature). The rows are the length bins and the columns are the time steps, in the same order in all three tables. Download the example workbook, keep a copy, and replace its values with yours.
| Location | Rule |
|---|---|
| Sheet names | Exactly data.CatL, data.wgt and data.mat (or three CSV files with these names) |
| Cell A1 | LengthBin; no title rows above the header |
| Column A | One length bin per row; the example uses the midpoints 6, 8, ..., 50 cm |
| Row 1 | Increasing numeric time labels: 2000, 2001, ... for years; 2000, 2000.25, 2000.5, ... for quarters |
| Other cells | One number per bin and time step; nothing else inside the grid |
| All three tables | Identical bins, time labels and order |
Under the three headings below, each table of the example is shown in full; the workbook and the CSV files in docs/data hold the same values. Scroll inside a table to see every time step. The header row and the LengthBin column stay in view. The line under each table gives the unit and a link to the CSV file.
Survey index table data.CatL
Enter the survey numbers at length, or a consistently standardized index of them (for example numbers per tow). Decimals are fine. The model outputs are on the scale of this index. With the default logistic curve, survey catchability rises to a fixed maximum of 1 for large fish, and no catchability scale is estimated. Abundance, biomass, spawning stock biomass (SSB), recruitment and catch are therefore absolute estimates only when the index is an absolute abundance estimate at length, such as swept-area numbers expanded to the stock area. With a relative index such as numbers per tow, read them as relative values in the units of the index and label the axes accordingly. Fishing mortality rates do not depend on the scale of the index. Leave a cell blank, or write NA, when that bin was not observed in that time step; do not write 0, a dash or <1 for an unknown value. A 0 means the survey observed nothing in that bin.
| LengthBin | 2000 | 2001 | 2002 | 2003 | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 6 | 0.051 | 0.052 | 0.050 | 0.045 | 0.074 | 0.070 | 0.042 | 0.047 | 0.068 | 0.091 | 0.091 | 0.073 | 0.141 | 0.057 | 0.089 | 0.077 | 0.091 | 0.070 | 0.058 | 0.068 |
| 8 | 0.628 | 0.546 | 0.718 | 0.661 | 0.970 | 0.817 | 0.616 | 0.563 | 0.927 | 1.156 | 1.224 | 1.169 | 1.413 | 0.709 | 1.527 | 0.924 | 1.293 | 1.003 | 0.787 | 0.965 |
| 10 | 4.359 | 3.447 | 4.688 | 4.512 | 5.941 | 5.588 | 4.061 | 4.375 | 5.528 | 7.326 | 6.686 | 5.727 | 12.068 | 4.124 | 8.322 | 6.158 | 7.568 | 7.239 | 5.300 | 5.667 |
| 12 | 10.810 | 11.685 | 12.823 | 11.288 | 18.656 | 14.587 | 10.084 | 9.356 | 15.742 | 19.106 | 17.483 | 15.486 | 29.684 | 13.166 | 22.869 | 17.813 | 19.451 | 17.465 | 15.544 | 17.330 |
| 14 | 15.885 | 15.698 | 16.082 | 14.556 | 19.057 | 15.950 | 15.415 | 17.418 | 18.464 | 27.282 | 21.486 | 19.372 | 34.749 | 21.800 | 25.067 | 20.443 | 21.395 | 20.644 | 23.098 | 21.883 |
| 16 | 14.562 | 16.691 | 18.503 | 20.989 | 16.001 | 22.719 | 19.682 | 18.077 | 17.938 | 19.474 | 27.338 | 21.179 | 29.914 | 37.583 | 26.263 | 35.977 | 25.125 | 29.548 | 29.125 | 21.258 |
| 18 | 23.906 | 25.402 | 25.911 | 23.532 | 25.197 | 37.362 | 34.123 | 23.611 | 23.248 | 24.242 | 41.306 | 34.931 | 40.509 | 67.792 | 37.920 | 56.559 | 32.026 | 55.458 | 40.007 | 28.944 |
| 20 | 28.233 | 34.756 | 27.398 | 38.750 | 33.124 | 45.841 | 41.000 | 32.108 | 28.891 | 36.974 | 45.557 | 47.177 | 53.760 | 73.083 | 52.489 | 71.402 | 39.277 | 60.945 | 46.603 | 50.352 |
| 22 | 28.348 | 39.232 | 36.386 | 38.339 | 31.586 | 50.190 | 41.964 | 35.212 | 37.523 | 36.300 | 50.689 | 44.032 | 47.411 | 91.149 | 49.491 | 66.939 | 55.077 | 64.979 | 52.063 | 45.473 |
| 24 | 28.082 | 37.957 | 31.028 | 34.271 | 31.798 | 34.658 | 46.587 | 36.214 | 27.230 | 28.641 | 39.798 | 41.808 | 44.396 | 57.939 | 50.331 | 49.151 | 43.936 | 45.674 | 51.172 | 40.304 |
| 26 | 28.245 | 26.872 | 29.590 | 25.295 | 27.235 | 34.068 | 33.868 | 28.013 | 21.883 | 25.064 | 27.792 | 32.642 | 39.713 | 37.368 | 61.690 | 42.334 | 44.729 | 41.408 | 37.639 | 31.083 |
| 28 | 28.718 | 22.331 | 20.814 | 28.357 | 19.118 | 25.332 | 35.072 | 28.766 | 17.997 | 16.660 | 22.959 | 27.493 | 32.652 | 38.015 | 48.165 | 37.582 | 50.442 | 35.735 | 39.543 | 30.399 |
| 30 | 28.097 | 23.433 | 21.526 | 18.842 | 22.410 | 21.959 | 21.563 | 25.002 | 22.270 | 18.878 | 18.689 | 27.499 | 30.936 | 37.641 | 48.203 | 38.818 | 40.672 | 35.313 | 38.424 | 34.942 |
| 32 | 26.733 | 23.884 | 23.505 | 21.477 | 21.958 | 19.223 | 19.130 | 29.268 | 22.446 | 14.788 | 18.170 | 23.732 | 19.519 | 24.964 | 46.787 | 43.646 | 34.964 | 29.821 | 27.729 | 27.486 |
| 34 | 22.475 | 21.356 | 19.002 | 17.755 | 16.067 | 15.904 | 20.218 | 21.983 | 16.415 | 13.222 | 14.963 | 14.837 | 23.862 | 22.789 | 28.379 | 28.943 | 31.350 | 25.622 | 28.890 | 25.261 |
| 36 | 19.101 | 18.578 | 18.859 | 15.417 | 16.048 | 12.772 | 15.859 | 14.823 | 16.722 | 10.636 | 10.696 | 10.941 | 23.943 | 21.762 | 28.357 | 27.810 | 31.847 | 28.107 | 24.176 | 23.356 |
| 38 | 23.274 | 17.941 | 16.710 | 12.625 | 11.754 | 12.125 | 12.811 | 14.679 | 16.843 | 10.048 | 9.812 | 9.704 | 16.257 | 19.597 | 23.907 | 27.812 | 24.685 | 24.799 | 21.766 | 23.948 |
| 40 | 14.010 | 12.787 | 13.319 | 11.726 | 12.046 | 10.131 | 10.835 | 11.939 | 10.688 | 10.602 | 7.098 | 7.951 | 12.513 | 14.684 | 16.169 | 24.329 | 21.661 | 17.339 | 19.226 | 18.752 |
| 42 | 14.261 | 14.228 | 13.469 | 10.695 | 9.149 | 9.341 | 8.486 | 11.255 | 10.221 | 8.993 | 6.664 | 6.442 | 9.824 | 11.708 | 14.519 | 20.444 | 17.261 | 22.943 | 19.086 | 14.987 |
| 44 | 10.647 | 12.967 | 12.128 | 10.601 | 9.573 | 9.102 | 8.436 | 9.006 | 8.848 | 6.846 | 5.480 | 5.551 | 7.644 | 8.557 | 13.029 | 14.712 | 15.745 | 13.252 | 12.943 | 12.937 |
| 46 | 10.830 | 7.708 | 8.576 | 8.971 | 8.434 | 6.487 | 7.685 | 6.780 | 6.909 | 5.001 | 4.624 | 4.997 | 5.970 | 6.932 | 8.845 | 9.627 | 13.024 | 13.551 | 11.041 | 12.069 |
| 48 | 8.175 | 8.333 | 7.671 | 6.838 | 5.876 | 5.500 | 5.845 | 5.947 | 5.677 | 4.534 | 5.199 | 4.041 | 4.439 | 6.243 | 7.136 | 10.215 | 12.761 | 11.368 | 10.809 | 9.265 |
| 50 | 23.574 | 34.476 | 30.263 | 27.598 | 21.905 | 22.323 | 23.716 | 20.083 | 19.631 | 17.765 | 12.645 | 15.074 | 13.959 | 17.829 | 23.602 | 33.391 | 35.615 | 31.310 | 41.726 | 34.306 |
data.CatL of the example data: numbers of fish caught in each length bin and time step. The table has 23 rows (length bins) and 20 columns of time steps (2000-2019). Values are rounded to 3 decimals for display; the file holds the unrounded values. Download data.CatL.csv.Weight table data.wgt
Enter the mean weight of one fish in each bin and time step, in one unit throughout (the example uses kg). Every cell needs a value, because the model multiplies numbers by weight to obtain biomass. If you have a length-weight relationship instead of yearly measurements, fill all time steps with its values and say so when you report the assessment.
| LengthBin | 2000 | 2001 | 2002 | 2003 | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 6 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 | 0.00133 |
| 8 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 | 0.00315 |
| 10 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 | 0.00614 |
| 12 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 | 0.01062 |
| 14 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 | 0.01686 |
| 16 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 | 0.02517 |
| 18 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 | 0.03583 |
| 20 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 | 0.04915 |
| 22 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 | 0.06542 |
| 24 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 | 0.08494 |
| 26 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 | 0.10799 |
| 28 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 | 0.13488 |
| 30 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 | 0.16589 |
| 32 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 | 0.20133 |
| 34 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 | 0.24149 |
| 36 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 | 0.28666 |
| 38 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 | 0.33715 |
| 40 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 | 0.39323 |
| 42 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 | 0.45521 |
| 44 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 | 0.52339 |
| 46 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 | 0.59805 |
| 48 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 | 0.67950 |
| 50 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 | 0.76803 |
data.wgt of the example data: mean weight of one fish, in kg. The table has 23 rows (length bins) and 20 columns of time steps (2000-2019). Values are rounded to 5 decimals for display; the file holds the unrounded values. Download data.wgt.csv.Maturity table data.mat
Enter the proportion mature as a number between 0 and 1 (0.6 for 60%). Every cell needs a value; 0 and 1 are valid. Spawning stock biomass is numbers times weight times maturity, so this table decides which bins count as spawners.
| LengthBin | 2000 | 2001 | 2002 | 2003 | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 6 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 8 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 10 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 12 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 14 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 16 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 18 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| 20 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 | 0.0001 |
| 22 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 | 0.0005 |
| 24 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 | 0.0015 |
| 26 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 | 0.0050 |
| 28 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 | 0.0160 |
| 30 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 | 0.0500 |
| 32 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 | 0.1460 |
| 34 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 | 0.3569 |
| 36 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 | 0.6431 |
| 38 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 | 0.8540 |
| 40 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 | 0.9500 |
| 42 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 | 0.9840 |
| 44 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 | 0.9950 |
| 46 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 | 0.9985 |
| 48 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 | 0.9995 |
| 50 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 | 0.9999 |
data.mat of the example data: proportion mature, from 0 to 1. The table has 23 rows (length bins) and 20 columns of time steps (2000-2019). Values are rounded to 4 decimals for display, so values below 0.00005 show as 0.0000; the file holds the unrounded values. Download data.mat.csv.2. Choose the time step and handle gaps
The models advance the population one time step at a time, and growth_step is the length of that step in years, 1 for annual surveys and 0.25 for quarterly surveys. Consecutive column labels must differ by exactly growth_step, so the models know how much time passed between two columns. A time step without a survey stays in the table as a column of blank survey cells with its weight and maturity filled in; the models then treat that step as unobserved.
| Situation | What to enter |
|---|---|
| Annual survey, no survey in 2002 | Keep a 2002 column; leave its survey cells blank; fill weight and maturity |
| Quarterly survey | Labels 2000, 2000.25, 2000.5, 2000.75, ...; growth_step = 0.25 in step 4 |
| One bin not observed in one time step | Leave that survey cell blank |
| A recorded zero | Keep the 0; decide in step 4 whether zeros are treated as missing (zero_action = "missing", the default) or stop the fit ("error") |
Supply length-bin midpoints (len_mid, one per row) and internal boundaries (len_border, one fewer than the rows). For equal-width bins, midpoints are the row labels and internal boundaries are halfway between them. Otherwise supply the boundaries used in your survey design. When the labels are single numbers with unequal spacing and len_border is missing, the fit sets the boundaries halfway between adjacent labels and gives a warning.
3. Read the files into R
Use one of the two readers. Both return a list with the three tables, convert numeric text to numbers, and stop with a message when the tables differ.
library(ALSCL)
# Once; only needed for Excel files.
if (getRversion() < "4.2.0") {
install.packages("remotes")
remotes::install_version("readxl", version = "1.4.5", upgrade = "never")
} else {
install.packages("readxl")
}
tables <- read_survey_excel("my_survey.xlsx")
str(tables)
On R 4.1, use readxl 1.4.5, which supports that R version. The code above chooses it automatically. CSV files do not need readxl.
# Three files data.CatL.csv, data.wgt.csv and data.mat.csv in one folder
tables <- read_survey_csv("my_data")
str(tables)
str(tables) should show three data frames with the same number of rows and columns, the first column of each being the length labels. A message such as "nonnumeric cell in time column 2003" points to a text entry in the grid; "must match data.CatL length labels and time columns" means the rows or columns of one table differ from the others. read_survey_excel() also stops when a cell holds an Excel error value such as #DIV/0! or #N/A, and names the sheet and the cells; only blank cells and NA denote missing values. Fix the file and read it again.
Details on cell values and the outer bins
Native numeric columns retain their precision when other time columns contain numeric text or factors. This also applies when you pass tables directly to run_acl() or run_alscl(); diagnostics read the same values. Complex-valued cells are invalid.
In the age-length probability calculation, the first and last bins absorb the normal distribution's lower and upper tails, with mathematical bounds of negative and positive infinity. The distribution is not truncated at zero; this is a probability-allocation convention, not a negative observed length.
4. Add the biology and build the input bundle
prepare_alscl_data() combines the three tables with the settings both models share, fit_args, into the input bundle x. The settings describe your stock and your survey; the models take them as given.
| Setting | Meaning | Where the value comes from |
|---|---|---|
rec.age |
Age of the youngest age class in the model, in years | Age at which fish first appear in the survey |
nage |
Number of age classes, including the oldest (plus) group | Choose the starting age A of the plus group on the age grid, in years. Set nage = 1 + (A - rec.age) / growth_step |
M |
Natural mortality rate per time step, as a single number or in one of the forms of the next subsection | The value of an accepted assessment of the stock where there is one. Otherwise an estimate from maximum age, an annual rate of 5.4 divided by the maximum age in years (Hamel and Cope 2022). Divide an annual value by 4 for quarterly steps |
sel_L50, sel_L95 |
Lengths at which survey catchability reaches 50% and 95% of its maximum, which is fixed at 1. Leave both out when survey_q is supplied |
Calibration or comparative fishing trials for the survey gear. If borrowing a curve, document the assumption and test sensitivity to it. |
survey_q, survey_q_age |
Optional. Survey catchability at length supplied directly, and a survey catchability multiplier by age class | Next subsection |
growth_step |
Years per time step | Step 2 |
len_mid, len_border |
Bin midpoints and internal boundaries | Step 2 |
zero_action |
How a 0 in the survey table is treated | "missing" (default) or "error" |
x <- prepare_alscl_data(tables, fit_args = list(
rec.age = 1, nage = 15, M = 0.2, sel_L50 = 15, sel_L95 = 20,
growth_step = 1, len_mid = seq(6, 50, 2), len_border = seq(7, 49, 2)))
saveRDS(x, "my_bundle.rds")
The numbers above are the settings of the synthetic example; replace them with the values for your stock. x is a plain list, so saveRDS() keeps it for later sessions and readRDS() brings it back. Starting values and a map for each model can be added later as fit_config; without them the models use their default starting values and fix the parameters listed in Fitting controls.
Natural mortality and survey catchability in other forms
mid <- seq(6, 50, 2)
# M by age class, the same in every time step: a matrix with one column
M_age <- matrix(c(0.4, 0.3, rep(0.2, 13)), ncol = 1)
# M by length bin (ALSCL only): inversely proportional to length, 0.2 at 40 cm
M_length <- lorenzen_M(mid, M_ref = 0.2, L_ref = 40)
round(M_length, 2)
# A dome-shaped survey catchability in place of sel_L50 and sel_L95
q_dome <- survey_catchability(mid, "dome", L50 = 15, L95 = 20,
L50_desc = 42, L95_desc = 34, minimum = 0.2)
round(q_dome, 2)
x_dome <- prepare_alscl_data(tables, fit_args = list(
rec.age = 1, nage = 15, M = M_age, survey_q = q_dome,
growth_step = 1, len_mid = mid, len_border = seq(7, 49, 2)))
check_alscl_data(x_dome, "acl")$valid
M has three forms, and its dim attribute tells them apart. A single number is one rate for all ages, lengths and time steps. A matrix with one row per age class is M by age. It has one column per time step, or one column that is used for every time step, so M by age that is constant over time is matrix(M_at_age, ncol = 1). A numeric vector without dimensions, with one value per length bin, is M by length. run_alscl() accepts it and run_acl() rejects it, because ACL follows numbers at age only. All values are rates per time step. The numbers in the block only show the forms.
lorenzen_M() returns M by length as M_ref * (length / L_ref)^exponent. The default exponent of -1 makes M inversely proportional to length, which is the change of M with length within populations that Lorenzen et al. (2022) found; Lorenzen (2022) describes departures from it below about 20% of the asymptotic length. M_ref is the rate at L_ref, and a single M from the literature usually stands for adult fish, so take L_ref as a length of adult fish from age readings or the literature. Do not use the Linf estimated by the model, because the assumed M would then depend on the fit that uses it. round(M_length, 2) prints 1.33 for the 6 cm bin and 0.16 for the 50 cm bin, so check the rates of the smallest bins before fitting.
survey_q replaces sel_L50 and sel_L95. It is a vector with one positive value per length bin, or a matrix with one row per length bin and one column per time step when catchability changed over time, for example after a change of survey gear. survey_catchability() computes a logistic curve or a dome-shaped curve with a maximum of 1. For the dome, L50_desc and L95_desc are the lengths at which the descending part is at 0.5 and 0.95, and minimum is the value that it approaches for the largest fish. survey_q_age is a multiplier by age class, with one positive value per age class, for example the relative catchability at age that an age-based assessment estimated for the same survey. Supplying survey_q together with sel_L50 or sel_L95 is an error. check_alscl_data() should return TRUE for the new bundle.
These inputs are assumptions, and the fit cannot check them. The survey index informs the total mortality rate and not its split into fishing and natural mortality, and a catchability that declines with length or age is fitted as higher mortality when it is not supplied (Model principles). Take M by age and time step from independent estimates, for example a multispecies model, and the shape of catchability from studies of the survey gear or from age data. Do not choose them by the objective of the fit. Record the source of each input and report how the results change with it (Judge whether a fit can be used).
5. Check the bundle before fitting
check <- check_alscl_data(x, "acl")
check$valid
check$errors
check$warnings
check$summary
plan <- inspect_parameters(x, "acl")
plan[, c("parameter", "status", "natural_start", "n_free")]
check_alscl_data() prepares the data exactly as a fit would, without compiling anything, and reports whether the bundle can be fitted. check$summary counts the bins, time steps, positive observations, zeros, blanks, time steps and bins without any observation, and the numbers of scalar (free_fixed) and random-effect (free_random) parameters that will be estimated. inspect_parameters() lists every parameter with its starting value on the natural scale and its status: free (estimated), fixed or tied. Run both again with "alscl" when you intend to fit that model.
If check$valid is FALSE, the messages in check$errors name the table, column or setting to correct; warnings point to things worth a look, such as many zeros or an unobserved time step. When the check passes, fit with run_acl(x) or run_alscl(x) and continue as in Understand your first fit.
Repository script and compatibility data
Scripts that call validate_survey_tables() or fit_survey_tables() from scripts/real_data_workflow.R in the repository still work; the script's readers call the package functions above. The package also ships example_data, three ALSCL tables with 9 bins and the years 2001-2021 whose species, units and bin boundaries are undocumented; use it only to try the functions.
What next
| What you want to do | Read |
|---|---|
| Fit the bundle and judge the result | Understand your first fit |
| Decide which parameters to fix or estimate, choose the F structure | Fitting controls |
| Follow a complete own-data example from CSV to saved results | How do I fit my own survey data? |
| Check the time grid of a quarterly survey | Annual and quarterly time steps |