-
Notifications
You must be signed in to change notification settings - Fork 53
Expand age and length composition
Jim Thorson edited this page Oct 15, 2020
·
9 revisions
It is possible to use VAST
to expand subsamples of age/length composition obtained during bottom-trawl sampling. To do so, we first perform first-stage expansion and then fit a spatio-temporal model to those expanded samples:
# Load packages
library(VAST)
# load data set
# see `?load_example` for list of stocks with example data
# that are installed automatically with `FishStatsUtils`.
example = load_example( data_set="Lingcod_comp_expansion" )
# Make settings
settings = make_settings( n_x = 50,
Region = example$Region,
purpose = "index2",
strata.limits = example$strata.limits,
use_anisotropy = FALSE,
fine_scale = FALSE )
# Run model
fit = fit_model( settings = settings,
Lat_i = example$sampling_data[,'Lat'],
Lon_i = example$sampling_data[,'Lon'],
t_i = example$sampling_data[,'Year'],
c_i = as.numeric(example$sampling_data[,'Length_bin'])-1,
b_i = example$sampling_data[,'First_stage_expanded_numbers'],
a_i = example$sampling_data[,'AreaSwept_km2'],
Npool = 40,
newtonsteps = 1,
test_fit = FALSE )
# Plot results
results = plot( fit,
check_residuals = FALSE )
# Calculate proportions
proportions = calculate_proportion( TmbData = fit$data_list,
Index = results$Index,
Year_Set = fit$year_labels )
Note: this code yields a slightly different result from those used for backwards-compatibility checks, due to differences in the k-means locations for knots between earlier reposited results and newer version of FishStatsUtils
. Also, using "Npool"=20
using the newer k-means results in a noninvertible Hessian, so I here use "Npool"=40
instead.
Example applications:
- Index standardization
- Empirical Orthogonal Functions
- Ordination using joint species distribution model
- End-of-century projections
- Expand length and age-composition samples
- Combine condition and biomass data
- Expand stomach content samples
- Combine presence/absence, counts, and biomass data
- Seasonal and annual variation
- Combine acoustic and bottom trawl data
- Surplus production models
- Multispecies model of biological interactions
- Stream network models
Usage demos:
- Adding covariates
- Visualize covariate response
- Percent deviance explained
- Create a new extrapolation grid
- Custom maps using ggplot
- Modify axes for distribution metrics
- K-fold crossvalidation
- Simulating new data
- Modify defaults for advanced users
Project structure and utilities: