MAR 580: Models for Marine Ecosystem-Based Management
TMB workshop
Session III
Programming bits, State-space models
08 September 2022
Review
Programming bits�(The “if” statement)
if (condition)
Statements-1;
else
Statements-2;
{ statement; statement; }
Constructing conditions
== Equal to (NOT =)
<= Less than or equal to
>= Greater than or equal to
< Less than
> Greater than
!= Not equal to
&& Condition is true if both sub-conditions are true
|| Condition is true if one of the sub-conditions is true
! Condition is true if sub-condition is false
The “for” statement
for (initial state; terminal condition; increment)
{ statements; }
biomass(1) = 1;
for (year=0; year<nyear; year++)
biomass(year+1)=biomass(year)*r;
Vector & matrix functions
http://kaskr.github.io/adcomp/matrix_arrays_8cpp-example.html
Extracting from arrays and matrices:
vector = matrix.col(index)
vector = matrix.row(index)
vector = matrix.diagonal();
Subvectors: extract a subset of a vector:
vector2 = vector1(index1,index2)
NB: arrays start at 0, so index1=2 is element 3!
Process error modeling in fisheries
State-space models
State-space modeling, hidden process
Observations
Fish population
Time
t = 0
t = 3
t = 2
t = 1
?
State-space modeling, hidden process
Observations
Fish population
Time
t = 0
t = 3
t = 2
t = 1
?
State-space modeling, hidden process
Observations
Fish population
Time
t = 0
t = 3
t = 2
t = 1
?
We are interested in separating variability associated with population process from that due to the observations.
State-space model: exponential growth
State-space model: exponential growth
Population growth rate
Population size at time t
Annual deviation in population growth, process error
Process error variance
State-space model: exponential growth
Population growth rate
Population size at time t
Annual deviation in population growth, process error
Observationat time t
Constant relating population size to observed values
Observation error residual
Process error variance
Observation error variance
State-space models: exponential growth
State-space models: exponential growth
State-space models: exponential growth
State-space models: exponential growth
We might be interested in estimating the values for these parameters!
State-space models, more generally
Relationship between models and parameters
Thorson & Minto (2015)
Inference for state-space models
Probability of the initial state.
Product over time steps t=1 to t=T.
Probability of state at time t conditional on state at time t-1 and the parameters of the state process model.
Probability of the observation at time t conditional on the state at time t and the parameters of the observation model.
Inference for state-space models
Maximum likelihood estimates for the model parameters
Likelihood of the parameters given the data from time t=1 to time=T.
Inference for state-space models
Estimating state-space models
Seminal work, for linear state and observation models when process and observation errors are Gaussian.
(Extended Kalman filter, unscented Kalman filter, etc.)
Estimating state-space models in TMB
Example: �SE Alaska Steller sea lion pup production
Exercise: Linear state-space production model
Schnute, J. T. (1994). A general framework for developing sequential fisheries models. Canadian Journal of Fisheries and Aquatic Sciences, 51(8), 1676-1688.
Initial biomass
LN(Bt) = LN(Bt) + r + beta*LN(Bt)
LN(Bt) = -r/beta
Pseudocode for cpp
Take homes
Recommended Reading
de Valpine, P., & Hastings, A. (2002). Fitting population models incorporating process noise and observation error. Ecological Monographs, 72(1), 57-76.
Harvey, A. C. (1990). Forecasting, structural time series models and the Kalman filter. Cambridge university press.
Holmes, E. E., Ward, E. J., & Wills, K. (2012). Marss: Multivariate autoregressive state-space models for analyzing time-series data. The R Journal, 4(1), 11-19.
Kalman, R. E. 1960. A new approach to linear filtering and prediction problems. Transactions of the ASME–Journal of Basic Engineering 82(Series D): 35–45.
Meinhold, R. J., & Singpurwalla, N. D. (1983). Understanding the Kalman filter. The American Statistician, 37(2), 123-127.
Nielsen, A. and Berg, C. W. 2014. Estimation of time-varying selectivity in stock assessments using state–space models. Fisheries Research 158(1):96–101.
Newman, K. B., Buckland, S. T., Morgan, B. J., King, R., Borchers, D. L., Cole, D. J., ... & Thomas, L. (2014). Modelling Population Dynamics. Springer.
Pedersen, M.W., Berg, C.W., Thygesen,U. H., Nielsen, A., and Madsen, H. 2011. Estimation methods for nonlinear state-space models in ecology. Ecological Modelling, 222: 1394–1400.
Punt, A. E. (2003). Extending production models to include process error in the population dynamics. Canadian Journal of Fisheries and Aquatic Sciences, 60(10), 1217-1228.
Schnute, J. T. (1994). A general framework for developing sequential fisheries models. Canadian Journal of Fisheries and Aquatic Sciences, 51(8), 1676-1688.
Thorson, J. T., & Minto, C. (2015). Mixed effects: a unifying framework for statistical modelling in fisheries biology. ICES Journal of Marine Science: Journal du Conseil, fsu213.