
tinyVAST model description
James T. Thorson
Source:vignettes/model-description.Rmd
model-description.Rmd
Bivariate generalized linear mixed model structure
tinyVAST (J. T. Thorson et al. 2025) is a bivariate extension of a generalized linear mixed model (see Tables 1 and 2 for notation), which includes two linear predictors that each include four additive components:
Spatial interactions among variables: The user can specify interactions among variables at a given site (or for spatially correlated latent variables) using arrow notation derived from path analysis, based on the interface from R package sem;
Temporal interaction among variables: The user can specify simultaneous and lagged interactions among variables over time using an expanded arrow-and-lag notation that is derived from R package dsem, where these interactions the annual intercept for a given variable therefore apply uniformly for all locations.
Spatio-temporal interactions among variables: The user can specify simultaneous and lagged interactions among variables over time, where these interactions occur on a site-by-site basis.
Generalized additive model: The user specifies a formula for a generalized additive model (GAM) that is interpreted by R package mgcv. If other model components are missing, tinyVAST estimates parameters that are similar to mgcv, with small differences resulting from different methods for parameter estimation;
These four components are assembled into two linear predictors:
where
- is the first linear predictor;
-
is the contribution of the GAM component specified using a formula
parsed by package
mgcv
; - is the GAM fixed effects with associated design matrix , where is the row of the design matrix for sample ;
- is the GAM random effects with associated design matrix , where is the row of the design matrix;
- is contribution of the space-veriable interaction projected to sample , where is the interpolation matrix with dimension such that row interpolates spatial vector for sample and variable ;
- is the contribution of the time-variable interaction for sample ;
- is the contribution of the space-variable-time interaction projected to sample ;
- is the contribution of spatially varying coefficients, i.e., a zero-centered and spatially varying slope that is projected to the location of samples, where these local slopes are then multiplied by user-supplied covariates in design matrix
and terms are defined similarly for the second linear predictor except using subscript-2. The linear predictors are then passed through a bivariate inverse-link function to specify the distribution for errors:
where
- probability density or mass function for sample ;
- is the bivariate inverse-link function that transforms linear predictors to the central tendancy parameters of the distribution;
- is the dispersion parameters for distribution for sample ;
In the simple case, the distribution only requires a single linear predictor such that by construction and drops out of the model. In this case, the model collapses to a generalized linear mixed model. For example we might have a log-link and Poisson distribution, such that it collapses to a log-linked Poisson GLMM, .
However, tinyVAST can also handle a delta-model using either logit-log or Poisson-linked link functions:
where and are the two linear predictors, such that ;
For the conventional logit-log bivariate link function we use a logit-link for encounter probabilities and a log-link for positive catch rates:
while for the Poisson-linked link function (J. T. Thorson 2018) we specify a complemetary log-log link for encounter probabilities and define the second link function such that :
where is the density for an underlying point process, and is biomass per point (i.e., animal or group).
In either the conventional or Poisson-linked delta model, is the encounter probability (and is fitted with a Bernoulli distribution), while is the central tendancy for positive values, i.e., .
Usefully, the interface allows analysts to specify a different distribution for different partitions of the data. This allows the model to jointly analyze different data types (GrΓΌss and Thorson 2019), or data with different magnitudes of sampling error.
Spatial domains
Linear predictors include spatially autocorrelated latent variables. These variables are treated as Gaussian Markov random fields (GMRFs), and evaluating the probability density of GMRFs involves calculating the precision matrix as the inverse of the spatial covariance matrix (J. Thorson and Kristensen 2024). tinyVAST involves three options for specifying this spatial precision:
Stochastic partial differentiaul equation (SPDE)
The analyst can approximate spatial variation over a continuous
two-dimensional surface by constructing finite element mesh (FEM),
treating the value at vertices as a GMRF, and then using bilinear
interpolation (i.e., a piecewise linear approximation) to interpolate
from vertices to the spatial domain. This method was developed by (F. Lindgren, Rue, and LindstrΓΆm 2011), as
popularized in the software R-INLA (Lindgren
2012), first implemented in TMB by (J. T.
Thorson et al. 2014), and using elements constructed by R-package
fmesher
(F. Lindgren 2023).
In this case, the precision is constructed as:
where every row of the interpolation matrix is nonzero for only the three vertices of the triangle that contains sample
Simultaneous autoregressive (SAR):
Alternatively, the analyst can apply a simultaneous autoregressive process (Ver Hoef, Hanks, and Hooten 2018), specifying an areal model that represents the value within spatial strata:
where is the adjacency matrix of the graph specified by the analyst, is the estimated partial correlation between adjacent areas, and each row of interpolation matrix is nonzero only for the single spatial stratum containing sample (and noting that adjacency matrix is different from interpolation matrix , but we use the same notation for both due to a collision in notational standards).
Stream networks using a tail-down exponential correlation function
Finally, the analyst can specify that sites are partially correlated if they are adjacent along a stream network (while ignoring flow direction). This results in an Onstein-Uhlenbeck process along the stream network (Charsley et al. 2023), or an exponential tail-down model:
where is a sparse diagonal matrix with diagonal elements
where is the distance from downstream (parent) node to upstream (child) node , and is the O-U parameter governing the decorrelation rate. Similarly, is a sparse matrix containing values , where: such that the regression slope predicting upstream node from downstream node . The spatial interpolation matrix again has row for each sampling or predictive location, and is nonzero for the two nodes immediately up and downstream from a given location, with values such that a given location is predicted as a weighted average based upon the distance from those two nodes.
For the SPDE and SAR spatial domains, the term is defined such that precision has unit variance. This is done because the spatial domain always arises in combination with other parameters, which are used to define the variance of the associated spatial variable.
Structural equation models
tinyVAST also involves specifying a structural equation model (SEM). This SEM be viewed either:
- Weak interpretation: as an expressive interface to parameterize the correlation among variables, using as many or few parameters as might be appropriate; or
- Strong interpretation: as a structural causal model, allowing predictions about the consequence of counterfactual changes to the system.
To specify a SEM, the user uses arrow notation derived from
package sem
(Fox 2006), as
described in TMB by (J. Thorson and Kristensen
2024). For example, to specify a linear model this involves:
This then estimates a single slope parameter (represented with a one-headed arrow), as well as the variance of and (specified with two-headed arrows). In a more complicated case, might cause , which in turn causes . This is then represented as:
# Path, parameter_name, start value
w1 -> w2, b_12, 0
w2 -> w3, b_23, 0
w1 <-> w1, s_1, 1
w2 <-> w2, s_2, 1
w3 <-> w3, s_3, 1
SEM interactions can be as complicated or simple as desired, and can include:
- Latent variables and loops (i.e., they are not restricted to directed acyclic graphs);
- Values that are fixed a priori, where the
parameter_name
is provided asNA
and the starting value that follows is the fixed value; - Values that are mirrored among path coefficients, where the same
parameter_name
is provided for multiple rows of the text file.
In this preceding example, path coefficients for one-headed arrows then define path matrix :
and coefficents for two-headed arrows define the Cholesky of the exnogenous covariance matrix :
These matrices are define a simultaneous equation model:
$$ \mathbf{ w = P w + \epsilon} \\ \mathbf\epsilon \sim \mathrm{MVN}( \mathbf 0, \mathbf G^T \mathbf G ) $$ where the variance . This then results in a sparse precision matrix:
where this precision matrix is then used as a modular component in the larger tinyVAST model.
Dynamic structural equation models
Similarly, tinyVAST involves specifying dynamic structural equation models (DSEM) (J. T. Thorson et al. 2024). To specify a DSEM, the user uses arrow-and-lag notation. For example, to specify a univariate first-order autoregressive process:
If there were four time-intervals () this would then result in the path matrix:
and when the DSEM involves multiple times and variables, the sparse precision is formed by summing across the Kronecker product of time-lag and interaction matrices. This DSEM defines a GMRF over a nonseparable interaction of time and variables, represented by a matrix with dimension . The user can specify a separate arrow-and-lag notation to define the precision matrix for the time-variable interaction and for the space-time-variable interaction .
The precision matrix for the time term is used to define the time-varying intercept for each variable:
Meanwhile, the space-time term is combined with the spatial precision as we explain next.
Spatial interactions for SEM and DSEM
tinyVAST uses the SEM and DSEM notation to construct the joint precision for the space-variable interaction with dimension , and the space-time-variable interaction with dimension . To do so, it constructs the separable precision for each process:
where the precision matrix has dimension to match the length of , and
where the precision matrix has dimension , to match the length of . This specification generalizes spatial factor analysis (Thorson et al. 2015) and spatial dynamic factor analysis (J. T. Thorson et al. 2016).
Generalized additive model
The analyst can specify a generalized additive model using syntax
from package mgcv
(Wood
2006), and parsed into TMB using an interface developed by
sdmTMB
(Anderson et al.
n.d.). For example this might involve:
If year
and species
are factors and
depth
and log_area
are continuous, then this
would specify a fixed effect for each level year
, a spline
smoother for depth
, using log_area
as an
offset, and estimating a random intercept for each level of
species
. This formula is parsed internally to assemble
fixed effects in design matrix
and the basis functions for spline smoothers and random effects in
design matrix
.
The coefficients
associated with smoothers and random effects are then specified to
follow a GMRF:
where is a blockwise diagonal matrix, assembled from estimated variance parameters and matrices constructed by mgcv.
Spatially varying coefficients
Finally, the analyst can account for spatial variation in the relationship between a specified covariate and the estimated response. This is done by specifying a spatially varying coefficient (SVC) (J. T. Thorson et al. 2023), and this can be used e.g.Β to account for spatially varying differences in catchability/detectability (GrΓΌss et al. 2023) or to account for nonlocal impacts of regional oceanographic indices (J. T. Thorson 2019). This involves estimating each SVC as a zero-centered Gaussian Markov random field while estimating its corresponding variance :
Any covariate specified as an SVC it is also typically specified in
the formula
to estimate a non-zero mean for the SVC. If the
estimated variance of the SVC approaches zero, it then suggests that the
covariate slope does not vary spatially.
Notation summary
Symbol | Description |
---|---|
Index for each sample, in | |
spatial coordinate for sample , in | |
time-interval for sample , in | |
category for sample , in | |
error distribution and link function for sample |
Symbol | Code | Description |
---|---|---|
y_i |
Observed response data | |
p_i |
first linear predictor | |
p2_i |
second linear predictor |