## ----setup, echo=FALSE, cache=FALSE-------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  echo = FALSE,
  error = FALSE,
  message = FALSE,
  warning = FALSE
)

## ----indices------------------------------------------------------------------
subscripts <- tibble::tribble(
  ~Symbol, ~Description,
  "$\\s$", "Index for space; a vector of x and y coordinates",
  "$t$", "Index for time",
  "$g$", "Level of a random-effect grouping factor",
  "$k$", "Random-effect grouping factor",
  "$p$", "Index for time-varying coefficient",
  "$l$", "Index for spatially varying coefficient (SVC)"
)
knitr::kable(subscripts, caption = "Table 1: Subscript notation", escape = FALSE, booktabs = TRUE)

## ----symbols, results='asis'--------------------------------------------------
symbols <- tibble::tribble(
   ~Symbol, ~Code, ~Description,
  "$y$", "`y_i`", "Observed response data",
  "$\\mu$", "`mu`", "Inverse-linked family parameter (usually the conditional response mean)",
  "$\\eta$", "`eta_i`", "Linear predictor before applying the inverse link ($f^{-1}$)",
  "$\\phi$", "`phi`", "A dispersion parameter for a distribution (estimated as `ln_phi`)",
  "$f$", "`fit$family$link`", "Link function",
  "$f^{-1}$", "`fit$family$linkinv`", "Inverse link function",
  "$\\boldsymbol{\\beta}$", "`b_j`", "Fixed-effect coefficient vector",
  "$\\bX$", "`X_ij`", "A predictor model matrix",
  "$\\bZ$", "`Zt_list`", "Random effect design matrix; $\\mathbf{z}_{k,\\s,t}$ is the row for one observation and grouping factor $k$",
  "$O_{\\s, t}$", "`offset_i`", "An offset variable at point $\\s$ and time $t$",

  "$\\omega_{\\s}$", "`omega_s`", "Spatial random field at point $\\s$ (vertex)",
  "$\\omega_{\\s}^*$", "`omega_s_A`", "Spatial random field at point $\\s$ (interpolated)",
  "$\\zeta_{\\s}$", "`zeta_s`", "Spatially varying coefficient random field at point $\\s$ (vertex)",
  "$\\zeta_{\\s}^*$", "`zeta_s_A`", "Spatially varying coefficient random field at point $\\s$ (interpolated)",
  "$\\epsilon_{\\s, t}$", "`epsilon_st`", "Spatiotemporal random field at point $\\s$ and time $t$ (vertex)",
  "$\\epsilon_{\\s, t}^*$", "`epsilon_st_A_vec`", "Spatiotemporal random field at point $\\s$ and time $t$ (interpolated)",
  "$\\delta_{\\s,t}$", "-", "AR(1) or random walk spatiotemporal innovations (vertex)",
  "$\\gamma_{p,t}$", "`b_rw_t`", "Time-varying coefficients",
  "$\\mathbf{b}_{k,g}$", "`re_b_pars`", "Vector of random intercepts/slopes for level $g$ of grouping factor $k$",

  "$\\boldsymbol{\\Sigma}_\\omega$", "-", "Spatial random field covariance matrix",
  "$\\boldsymbol{\\Sigma}_\\zeta$", "-", "Spatially varying coefficient random field covariance matrix",
  "$\\boldsymbol{\\Sigma}_\\epsilon$", "-", "Spatiotemporal marginal covariance (IID/AR1) or innovation covariance (RW)",
  "$\\bQ_\\omega$", "`Q`", "Spatial random field precision matrix (code omits $\\tau^2$)",
  "$\\bQ_\\zeta$", "`Q`", "Spatially varying coefficient precision matrix; shares $\\kappa_\\omega$, with its own $\\tau$ (code omits $\\tau^2$)",
  "$\\bQ_\\epsilon$", "`Q_st`", "Spatial precision matrix of the spatiotemporal process; `Q` if the range is shared (code omits $\\tau^2$)",
  "$\\bSigma_{k}$", "`re_cov_pars`", "Random effect covariance matrix for grouping factor $k$ (log SDs and correlation parameters)",

  "$\\sigma_\\omega$", "`sigma_O`", "Spatial marginal SD for SPDE fields; scale parameter for SAR/CAR",
  "$\\sigma_\\epsilon$", "`sigma_E`", "Spatiotemporal marginal SD (IID/AR1) or innovation SD (RW); scale parameter for SAR/CAR",
  "$\\sigma_\\zeta$", "`sigma_Z`", "Spatially varying coefficient marginal SD for SPDE fields; scale parameter for SAR/CAR",
  "$\\sigma_\\gamma$", "`sigma_V`", "Time-varying coefficient innovation SD (RW/RW0) or stationary marginal SD (AR1)",
  "$\\tau$", "`ln_tau_O`, `ln_tau_E`, `ln_tau_Z`", "SPDE precision scaling parameters (log scale)",
  "$\\kappa_\\omega$", "`kappa[1, ]`", "Spatial Matérn scaling parameter (estimated as `ln_kappa`)",
  "$\\kappa_\\epsilon$", "`kappa[2, ]`", "Spatiotemporal Matérn scaling parameter",
  "$\\sqrt{8}/\\kappa$", "`range`", "Distance at which correlation drops to approximately 0.13",

  "$\\rho$", "`rho`", "Correlation between spatiotemporal random fields in subsequent time steps (estimated as `ar1_phi`)",
  "$\\rho_{\\gamma}$", "`rho_time`", "Correlation between time-varying coefficients in subsequent time steps",
  "$\\rho_{\\mathrm{SAR}}$", "`rho_sar`", "SAR spatial autocorrelation parameter",
  "$\\alpha_{\\mathrm{CAR}}$", "`alpha_car`", "CAR spatial autocorrelation parameter",
  "$\\lambda$, $c$", "`s_slope`, `s_cut`", "Breakpoint slope and break point",
  "$s50$, $s95$, $\\psi$", "`s50`, `s95`, `s_max`", "Logistic threshold parameters",
  "$\\kappa_S$, $\\kappa_T$", "`kappaS_nl`, `kappaT_nl`", "Nonlocal (distributed lag) spatial and temporal scale parameters",
  "$p$ (Tweedie)", "`tweedie_p`", "Tweedie power parameter (estimated as `thetaf`)",
  "$\\nu$", "`student_df`", "Student-t degrees of freedom",
  "$\\Qg$", "`gengamma_Q`", "Generalized gamma shape parameter ($Q \\rightarrow 0$ gives lognormal; $Q=\\phi$ gives gamma)",
  "$c_1$, $c_2$", "`psi`", "Ordered beta cutpoints",
  "$p$ (mixture)", "`p_extreme`", "Probability of the larger mixture component",
  "$\\bA$", "`A_station`", "Sparse projection matrix to interpolate from mesh vertices to the unique data or prediction locations",
  "$\\bH$", "`H`", "2-parameter matrix defining geometric anisotropy (estimated as `ln_H_input`)"
)
knitr::kable(symbols, caption = "Table 2: Symbol notation, names in the model output or RTMB model code, and descriptions.", escape = FALSE, booktabs = TRUE,
   linesep = c(
    rep('', 9), # data, mean, link, fixed effects
    '\\addlinespace',
    rep('', 8), # random effects and fields
    '\\addlinespace',
    rep('', 6), # covariance and precision
    '\\addlinespace',
    rep('', 7), # standard deviations and range
    '\\addlinespace',
    rep('', 99) # other parameters
  ))

