This guide describes the simulated fishery, the survey design, the
estimators and the planted artefacts. The app’s Guide tab has a
plain-language version. For worked examples see
vignette("casimir-02-user-guide") and
vignette("casimir-03-teaching").
1. What casimir does
casimir (Catch Sampling Inference Methods in R) simulates a small-scale fishery whose true landings are known, and the landing-site surveys that try to estimate them. It is built for training in catch assessment surveys: trainees design a stratified multi-stage survey, roll a sample, raise it to catch per species with the estimators of the FAO training, and spin the design many times to see its bias, precision and cost, for catch by species and for effort (landings, i.e. fishing trips).
A casimir run has seven layers, each a plain R function:
| # | Layer | Function | Object |
|---|---|---|---|
| 1 | Island (fishery) | cas_fishery(island_x()) |
cas_fishery |
| 2 | Frame survey | frame_survey() |
cas_frame |
| 3 | Design | cas_design() |
cas_design |
| 4 | Roll (sample) | draw_sample() |
cas_sample (forms A-C) |
| 5 | Raise (estimate) | estimate_catch() |
cas_estimate |
| 6 | Series (survey years) |
run_survey(), catch_by(),
effort_by()
|
cas_survey |
| 7 | Spin (evaluate) |
replicate_design(), compare_designs();
over the years spin_series()
|
cas_eval, cas_spins
|
| - | Truth |
cas_truth(), cas_effort_truth(),
check_estimate(), planted_artefacts()
|
answer key |
| - | Cash out |
export_survey(), spins_long()
|
csv files, long table |
Seeds are derived per stream with seed_for(seed, tag),
so a new sample does not change the fishery, and designs compared on the
same fishery share the same random draws where they overlap.
2. The island: landing sites, segments and ranges
The fishery comes from the logbook simulator of cpueTargeting
(simulate_logbook()): ten demersal and pelagic species on a
shelf-to-slope grid with reef patches and a temperature gradient,
Schaefer dynamics, and a fleet that chooses a tactic (reef handline,
sediment longline, pelagic troll) and a cell by expected value. casimir
switches on its optional landing layer
(landing_settings()):
- each boat has a home landing site on the coast,
drawn by site type and segment (
site_mix); - the weight of each cell in the choice of where to fish is multiplied
by the segment’s reach from the home site,
exp(-(d / range)^2); - each trip gets a fishing day (no fishing on Sundays, at most one trip per boat and day where possible) and a landing hour (departure + hours fished + travel).
island_x() sets up Island X of the FAO training concept
by Pedro Barros (Data Collection and Estimation of Fisheries
Quantities): nine sites of three types (Harbour, Beach, Jetty) and
three segments.
| Segment | Boats | Range | Home tactics | Based at |
|---|---|---|---|---|
| canoe | 150 | 5 cells (12.5 km) | Reef | beaches, jetties |
| small_motor | 60 | 12 cells (30 km) | Reef, Sediment | all site types |
| large_motor | 15 | 25 cells (62.5 km) | Pelagic, Sediment | harbours, some jetties |
The simulation runs for ten years and the survey programme covers the
last five; the earlier years let stocks respond to fishing and the fleet
change. Fishing pressure is moderate (catchability
q = 0.004; the valuable reef species Dentex
dentex, most exposed to the canoes, at 30% of the default
catchability), so stocks decline without collapsing.
Boats join and leave the fleet over the whole period
(island_x(entry = 0.4, exit = 0.1): 40% of the boats join
after year 1, 10% leave), and trips per year grow with the number of
active boats. The fleet grows by about half over ten years, so a frame
survey that is not repeated goes out of date. fish$landings
holds every trip with its site, date, segment and true landed weight by
species: the census the survey estimates.
3. Frame survey and design
frame_survey() lists boats by site and segment (active
in a reference year) and fishing days by quarter. The
PSU is a landing site on a fishing day; strata are
site type x quarter, and each visit records all
segments, so each segment is raised in its own stratum (site type x
quarter x segment).
cas_design() sets the stages:
| Stage | Unit | Setting | Recorded on |
|---|---|---|---|
| 1 | site-day |
m per site type and quarter; psu_select =
"srs" or "systematic"
|
Form A: N, landings counted by segment |
| 2 | landing |
n per segment and visit (all if fewer land) |
Form B: W, landed kg; hours fished |
| 3 | subsample |
w_kg per landing, in baskets of
unit_kg
|
Form C: species weights w_s |
The subsample is drawn as w_kg / unit_kg baskets, each
filled with the species mix of the landing (multinomial), so small
subsamples miss rare species. design_cost() counts
enumerator-hours per visit, landing and kg.
4. Estimators
estimate_catch() raises one stage at a time:
Step 1 landing W_ijs = w_ijs / sum_s(w_ijs) * W_ij
Step 2 site-day W_is = N_i / n_i * sum_j W_ijs
Step 3 stratum W_hs = M_h / m_h * sum_i W_is
Step 4 total W_s = sum_h W_hs
Site-days with no landings of a segment count, with a catch of zero. The variance of step 3 is the ultimate-cluster estimator with the stage-1 finite population correction,
V(W_hs) = M_h^2 (1 - m_h / M_h) s^2_h / m_h
where s^2_h is the variance of the site-day totals; the
second-stage term
M_h / m_h sum_i N_i^2 (1 - n_i / N_i) s^2_i / n_i is
returned as var_within. A census (all site-days, all
landings, whole landings) recovers the true catch exactly, and over
replicates the estimator is unbiased (tests in
tests/testthat).
The CPUE x effort route
(route = "effort") multiplies the mean catch per landing in
the stratum by frame boats x fishing days x boat activity (landings
counted per frame boat on the visited days). It agrees with the PSU
route on average when the frame is up to date.
5. Catch by segment and the five-year programme
catch_by(estimate, by = "segment") sums the stratum
estimates by species and segment (or site type, or quarter), with
variances added over strata. run_survey() rolls and raises
the same design in each survey year (by default the last five of the ten
simulated years); frame = "first" keeps the frame survey of
the first year throughout, so it ages as boats enter and leave.
plot_series() shows the estimates with intervals against
the truth.
Effort, the number of landings (fishing trips), is estimated
alongside the catch: M_h / m_h * sum_i N_i from the
landings counted on Form A, or frame boats x days x activity on the CPUE
x effort route. effort_by() and
plot_effort_series() compare it with the census
(cas_effort_truth()).
spin_series() repeats the whole programme R
times; summary_spins() and plot_spin_series()
(a band of the middle 95% of the estimates, or paired bars) show the
spread year by year against the truth, and spins_long()
returns every estimate with its truth as one long table (iter, year,
quarter, site type, segment, species).
On Island X boats join the fleet over the years
(island_x(entry, exit)) and trips grow with the number of
boats, so an old frame survey underestimates effort and catch more each
year.
6. Planted artefacts
artefacts() switches on field problems;
planted_artefacts() lists them for the answer key.
| Artefact | Setting | Effect |
|---|---|---|
| High roller | high_roller = 0-1 |
landings chosen with probability proportional to
W^(3 * high_roller): catch biased up |
| Short watch | short_watch = hour |
later landings neither counted nor sampled: long-range segments and their species biased down |
| Easy sites | easy_sites = c(...) |
only these sites visited, M counts all: biased if their grounds differ |
| Dropped zeros | dropped_zeros = TRUE |
visits with no landings not recorded: catch biased up |
| Top of the box | top_of_box = 0-1 |
subsample favours valuable species: species split biased |
| Old frame | old_frame = years |
frame boats out of date: CPUE x effort route biased |
7. Spin: bias, CV and coverage
replicate_design() repeats Roll and Raise R
times on the same island and compares the totals with the truth:
relative bias (the house edge), CV, coverage of the 95% intervals and
RMSE. compare_designs() does this for several designs, and
days_vs_boats() builds designs of about equal cost that
trade site-days for landings per visit.
spin_series() spins the whole programme: every replicate
rolls and raises the design in each survey year.
summary_spins() gives, per year, the mean and the middle
95% of the estimates against the truth, with bias and coverage;
plot_spin_series() draws them as a band or as paired bars,
for catch by species or effort by segment. spins_long()
returns every estimate with its truth as one long table (iter, year,
quarter, site type, segment, species), ready for csv or rds.
Coverage below 0.95 is expected for species whose catches are skewed (a few large landings) when strata have few site-days: the normal interval is too narrow. It is a teaching point, not an error.