Skip to contents

Creating a new model

Mizer allows the easy set-up of four different types of models, of increasing level of complexity. See https://sizespectrum.org/mizer/articles/mizer.html#size-spectrum-models for a description of these model types.

newSingleSpeciesParams() experimental
Set up parameters for a single species in a power-law background
newCommunityParams()
Set up parameters for a community-type model
newTraitParams()
Set up parameters for a trait-based multispecies model
newMultispeciesParams()
Set up parameters for a general multispecies model
mizer mizer-package
mizer: Multi-species size-based modelling in R
defaults_edition()
Default editions

Changing model parameters

After you have created a model, you will want to make changes to it while tuning the model and for investigating the impact of changes in parameters.

Steady state tuning

The first task after creating a multi-species model is to tune the model parameters so that in its steady state the model reproduces average observed growth rates, abundances and fisheries yields.

steady()
Set initial values to a steady state for the model
steadySingleSpecies() experimental
Set initial abundances to solution of steady-state equation with current rates
matchGrowth()
Adjust model to produce observed growth
plotBiomassObservedVsModel() plotlyBiomassObservedVsModel() experimental
Plotting observed vs. model biomass data
calibrateBiomass() experimental
Calibrate the model scale to match total observed biomass
calibrateNumber() experimental
Calibrate the model scale to match total observed number
matchBiomasses() experimental
Match biomasses to observations
matchNumbers() experimental
Match numbers to observations
plotYieldObservedVsModel() plotlyYieldObservedVsModel() experimental
Plotting observed vs. model yields
scaleModel() experimental
Change scale of the model
scaleRates()
Rescale all rates in a mizer model

Dynamics tuning

After tuning the steady state, you need to tune the sensitivity of the dynamics to perturbations away from the steady state. The following functions allow you to change the model without destroying the steady state.

Sharing models

setMetadata() getMetadata() experimental
Set metadata for a model
saveParams() readParams() saveSim() readSim()
Save and restore mizer objects

Running simulations

project()
Project size spectrum forward in time
projectToSteady() experimental
Project to steady state
setInitialValues()
Set initial values to values from a simulation

Accessing results

N() NResource()
Time series of size spectra
finalN() finalNResource() idxFinalT()
Size spectra at end of simulation
getEffort()
Fishing effort used in simulation
getTimes()
Times for which simulation results are available

Analysing results

summary_functions
Description of summary functions
getBiomass()
Calculate the total biomass of each species within a size range at each time step.
getDiet()
Get diet of predator at size, resolved by prey species
getGrowthCurves()
Get growth curves giving weight as a function of age
getN()
Calculate the number of individuals within a size range
getSSB()
Calculate the SSB of species
getTrophicLevel() experimental
Get trophic level of individuals at size
getTrophicLevelBySpecies() experimental
Get mean trophic level of each species
getYield()
Calculate the rate at which biomass of each species is fished
getYieldGear()
Calculate the rate at which biomass of each species is fished by each gear

Calculating indicators

indicator_functions
Description of indicator functions
getCommunitySlope()
Calculate the slope of the community abundance
getMeanMaxWeight()
Calculate the mean maximum weight of the community
getMeanWeight()
Calculate the mean weight of the community
getProportionOfLargeFish()
Calculate the proportion of large fish

Plotting results

plotting_functions
Description of the plotting functions
animate() animateSpectra()
Animate size-dependent quantities through time
plot(<ArraySpeciesBySize>) ggplotly(<ArraySpeciesBySize>) plot(<ArrayTimeBySpecies>) ggplotly(<ArrayTimeBySpecies>) plot(<ArrayTimeBySpeciesBySize>) ggplotly(<ArrayTimeBySpeciesBySize>)
Plotting outputs
plot2()
Compare two mizer array objects in one plot
plotBiomass() plotlyBiomass()
Plot the biomass of species through time
plotBiomassObservedVsModel() plotlyBiomassObservedVsModel() experimental
Plotting observed vs. model biomass data
plotCDF() plotlyCDF()
Plot cumulative abundance or biomass distributions
plotCDF2() plotlyCDF2()
Compare two cumulative abundance or biomass distributions
plotDiet() plotlyDiet() experimental
Plot diet, resolved by prey species, as function of predator at size.
plotFMort() plotlyFMort()
Plot total fishing mortality of each species by size
plotFeedingLevel() plotlyFeedingLevel()
Plot the feeding level of species by size
plotGrowthCurves() plotlyGrowthCurves()
Plot growth curves
plot(<MizerParams>)
Summary plot for MizerParams objects
plot(<MizerSim>)
Summary plot for MizerSim objects
plotPredMort() plotlyPredMort()
Plot predation mortality rate of each species against size
plotRelative()
Plot the relative difference between two mizer array objects
plotSpectra() plotlySpectra()
Plot the abundance spectra
plotSpectra2() plotlySpectra2()
Compare two size spectra in the same plot
plotSpectraRelative() plotlySpectraRelative()
Plot the relative difference between two spectra
plotYield() plotlyYield()
Plot the total yield of species through time
plotYieldGear() plotlyYieldGear()
Plot the total yield of each species by gear through time
plotYieldObservedVsModel() plotlyYieldObservedVsModel() experimental
Plotting observed vs. model yields
addPlot() experimental
Add values to an existing plot
setColours() getColours() setLinetypes() getLinetypes() experimental
Set line colours and line types to be used in mizer plots

Manipulating species list

addSpecies()
Add new species
removeSpecies()
Remove species
renameSpecies() experimental
Rename species
markBackground()
Designate species as background species
removeBackgroundSpecies()
Remove all background species

Setting custom rates

You can override the rates mizer calculates from the species parameters and gear parameters with your own rate arrays.

Calculating rates

getDiffusion()
Get diffusion rate from predation
getEGrowth()
Get energy rate available for growth
getERepro()
Get energy rate available for reproduction
getEReproAndGrowth()
Get energy rate available for reproduction and growth
getEncounter()
Get encounter rate
getFMort()
Get the total fishing mortality rate from all fishing gears by time, species and size.
getFMortGear()
Get the fishing mortality by time, gear, species and size
getFeedingLevel()
Get feeding level
getFlux()
Get flux into size bins
getMort()
Get total mortality rate
getPredMort()
Get total predation mortality rate
getPredRate()
Get predation rate
getRDD()
Get density dependent reproduction rate
getRDI()
Get density independent rate of egg production
getRates()
Get all rates
getResourceMort()
Get predation mortality rate for resource
getCriticalFeedingLevel()
Get critical feeding level
setRateFunction() getRateFunction() other_params() `other_params<-`()
Set own rate function to replace mizer rate function
setComponent() removeComponent() getComponent()
Add a dynamical ecosystem component
`initialNOther<-`() initialNOther()
Initial values for other ecosystem components
NOther() finalNOther()
Time series of other components
clearExtensionChain()
Clear the registered extension chain
coerceToExtensionClass()
Coerce a mizer object to its registered extension class
getRegisteredExtensions()
Get the registered mizer extension chain
registerExtension()
Register a single mizer extension for this R session
registerExtensions()
Register mizer extensions for this R session
customFunction() experimental
Replace a mizer function with a custom version

Predation kernels

box_pred_kernel()
Box predation kernel
lognormal_pred_kernel()
Lognormal predation kernel
power_law_pred_kernel()
Power-law predation kernel
truncated_lognormal_pred_kernel()
Truncated lognormal predation kernel

Fishing selectivity functions

double_sigmoid_length()
Length based double-sigmoid selectivity function
knife_edge()
Weight based knife-edge selectivity function
sigmoid_length()
Length based sigmoid selectivity function
sigmoid_weight()
Weight based sigmoidal selectivity function

Resource dynamics

resource_constant()
Keep resource abundance constant
resource_logistic() balance_resource_logistic()
Project resource using logistic model
resource_semichemostat() balance_resource_semichemostat()
Project resource using semichemostat model
resource_params() `resource_params<-`()
Resource parameters

Reproduction functions

BevertonHoltRDD()
Beverton Holt function to calculate density-dependent reproduction rate
RickerRDD() experimental
Ricker function to calculate density-dependent reproduction rate
SheperdRDD() experimental
Sheperd function to calculate density-dependent reproduction rate
constantEggRDI() experimental
Choose egg production to keep egg density constant
constantRDD() experimental
Give constant reproduction rate
noRDD()
Give density-independent reproduction rate
projectRDD()
Get density-dependent reproduction rate during projection
getReproductionLevel()
Get reproduction level
getRequiredRDD()
Determine reproduction rate needed for initial egg abundance

Internal rate functions

These functions are used by project() to calculate instantaneous rates at each time step. You should use the get…() functions instead of the mizer…() functions.

mizerRates() projectRates()
Get all rates needed to project standard mizer model
projectDiffusion() mizerDiffusion()
Calculate diffusion rate
projectEGrowth() mizerEGrowth()
Get energy rate available for growth needed to project standard mizer model
projectERepro() mizerERepro()
Get energy rate available for reproduction needed to project standard mizer model
projectEReproAndGrowth() mizerEReproAndGrowth()
Get energy rate available for reproduction and growth needed to project standard mizer model
projectEncounter() mizerEncounter()
Get encounter rate during projection
projectFMort() mizerFMort()
Get the total fishing mortality rate from all fishing gears
mizerFMortGear()
Get the fishing mortality needed to project standard mizer model
projectFeedingLevel() mizerFeedingLevel()
Get feeding level needed to project standard mizer model
projectMort() mizerMort()
Get total mortality rate needed to project standard mizer model
projectPredMort() mizerPredMort()
Get total predation mortality rate needed to project standard mizer model
projectPredRate() mizerPredRate()
Get predation rate needed to project standard mizer model
projectRDI() mizerRDI()
Get density-independent rate of reproduction needed to project standard mizer model
projectResourceMort() mizerResourceMort()
Get predation mortality rate for resource needed to project standard mizer model

Internal helper functions

age_mat()
Calculate age at maturity
age_mat_vB()
Calculate age at maturity from von Bertalanffy growth parameters
calc_selectivity()
Calculate selectivity from gear parameters
constant_other()
Helper function to keep other components constant
default_pred_kernel_params()
Set defaults for predation kernel parameters
different()
Check whether two objects are different
distanceMaxRelRDI() experimental
Measure distance between current and previous state in terms of RDI
distanceSSLogN() experimental
Measure distance between current and previous state in terms of fish abundances
emptyParams()
Create empty MizerParams object of the right size
get_f0_default()
Get default value for f0
get_gamma_default()
Get default value for gamma
get_initial_n()
Calculate initial population abundances
get_ks_default()
Get default value for ks
get_phi()
Get values from feeding kernel function
get_size_range_array()
Get size range array
get_steady_state_n()
Calculate steady state abundance
get_time_elements()
Get array indices for a time range in a MizerSim object
l2w() w2l()
Length-weight conversion
needs_upgrading()
Determine whether a MizerParams or MizerSim object needs to be upgraded
project_n() project_n_no_diffusion()
Project values for first time step of Euler method
project_n_2()
Project values with a predictor-corrector method
project_simple()
Project abundances by a given number of time steps into the future
set_species_param_default()
Set a species parameter to a default value
validGearParams()
Check validity of gear parameters and set defaults
validSpeciesParams() validGivenSpeciesParams()
Validate species parameter data frame
valid_gears_arg()
Helper function to assure validity of gears argument
valid_species_arg()
Helper function to assure validity of species argument

Classes

MizerParams-class
A class to hold the parameters for a size based model.
summary(<MizerParams>)
Summarize MizerParams object
compareParams()
Compare two MizerParams objects and print out differences
w() w_full() dw() dw_full()
Size bins
validParams()
Validate MizerParams object and upgrade if necessary
MizerSim-class
A class to hold the results of a simulation
summary(<MizerSim>)
Summarize MizerSim object
getSimParams()
Extract the projection parameters used to produce a simulation
validSim()
Validate MizerSim object and upgrade if necessary
MizerSim()
Constructor for the MizerSim class
getParams()
Extract the parameter object underlying a simulation
print(<ArraySpeciesBySize>) print(<ArrayTimeBySpecies>) print(<ArrayTimeBySpeciesBySize>) print(<summary.ArraySpeciesBySize>) print(<summary.ArrayTimeBySpecies>) print(<summary.ArrayTimeBySpeciesBySize>)
Print mizer objects
summary(<MizerParams>) summary(<MizerSim>) summary(<ArraySpeciesBySize>) summary(<ArrayTimeBySpecies>) summary(<ArrayTimeBySpeciesBySize>)
Summarise mizer objects
as.data.frame(<ArraySpeciesBySize>) as.data.frame(<ArrayTimeBySpecies>) as.data.frame(<ArrayTimeBySpeciesBySize>)
Convert mizer arrays to data frames
ArraySpeciesBySize()
S3 class for species x size rate arrays
is.ArraySpeciesBySize()
Test if an object is a ArraySpeciesBySize
ArrayTimeBySpecies()
S3 class for time x species arrays
is.ArrayTimeBySpecies()
Test if an object is a ArrayTimeBySpecies
ArrayTimeBySpeciesBySize()
S3 class for time x species x size arrays
is.ArrayTimeBySpeciesBySize()
Test if an object is an ArrayTimeBySpeciesBySize

Example parameter sets

More example parameter sets are available via https://sizespectrum.org/mizerExamples

NS_params
Example MizerParams object for the North Sea example
NS_species_params
Example species parameter set based on the North Sea
NS_species_params_gears
Example species parameter set based on the North Sea with different gears
NS_interaction
Example interaction matrix for the North Sea example
NS_sim
Example MizerSim object for the North Sea example

Deprecated

These functions are available for backwards compatibility with earlier versions of mizer

MizerParams() deprecated
Alias for set_multispecies_model()
calibrateYield() deprecated
Calibrate the model scale to match total observed yield
completeSpeciesParams() deprecated
Alias for validSpeciesParams()
getESpawning() deprecated
Alias for getERepro()
getM2() deprecated
Alias for getPredMort()
getM2Background() deprecated
Alias for getResourceMort()
getPhiPrey() deprecated
Get available energy
getZ() deprecated
Alias for getMort()
inter deprecated
Alias for NS_interaction
matchYields() deprecated
Match yields to observations
plotM2() deprecated
Alias for plotPredMort()
setRmax() deprecated
Alias for setBevertonHolt()
set_community_model() deprecated
Deprecated function for setting up parameters for a community-type model
set_multispecies_model() deprecated
Deprecated obsolete function for setting up multispecies parameters
set_trait_model() deprecated
Deprecated function for setting up parameters for a trait-based model