Skip to contents

Extract a relative biomass/abundance index or a center of gravity

Usage

get_index(
  obj,
  bias_correct = FALSE,
  level = 0.95,
  area = 1,
  silent = TRUE,
  ...
)

get_cog(
  obj,
  bias_correct = FALSE,
  level = 0.95,
  format = c("long", "wide"),
  area = 1,
  silent = TRUE,
  ...
)

Arguments

obj

Output from predict.sdmTMB() with return_tmb_object = TRUE.

bias_correct

Should bias correction be implemented TMB::sdreport()?

level

The confidence level.

area

Grid cell area. A vector of length newdata from predict.sdmTMB() or a value of length 1, which will be repeated internally to match.

silent

Silent?

...

Passed to TMB::sdreport().

format

Long or wide.

Value

For get_index(): A data frame with a columns for time, estimate, lower and upper confidence intervals, log estimate, and standard error of the log estimate.

For get_cog(): A data frame with a columns for time, estimate (center of gravity in x and y coordinates), lower and upper confidence intervals, and standard error of center of gravity coordinates.

References

Geostatistical random-field model-based indices of abundance (along with many newer papers):

Shelton, A.O., Thorson, J.T., Ward, E.J., and Feist, B.E. 2014. Spatial semiparametric models improve estimates of species abundance and distribution. Canadian Journal of Fisheries and Aquatic Sciences 71(11): 1655--1666. doi:10.1139/cjfas-2013-0508

Thorson, J.T., Shelton, A.O., Ward, E.J., and Skaug, H.J. 2015. Geostatistical delta-generalized linear mixed models improve precision for estimated abundance indices for West Coast groundfishes. ICES J. Mar. Sci. 72(5): 1297–1310. doi:10.1093/icesjms/fsu243

Geostatistical model-based centre of gravity:

Thorson, J.T., Pinsky, M.L., and Ward, E.J. 2016. Model-based inference for estimating shifts in species distribution, area occupied and centre of gravity. Methods Ecol Evol 7(8): 990–1002. doi:10.1111/2041-210X.12567

Bias correction:

Thorson, J.T., and Kristensen, K. 2016. Implementing a generic method for bias correction in statistical models using random effects, with spatial and population dynamics examples. Fisheries Research 175: 66–74. doi:10.1016/j.fishres.2015.11.016

See also

Examples

# \donttest{
# Use a small number of knots for this example to make it fast:
pcod_spde <- make_mesh(pcod, c("X", "Y"), n_knots = 60, type = "kmeans")
m <- sdmTMB(
 data = pcod,
 formula = density ~ 0 + as.factor(year),
 time = "year", mesh = pcod_spde, family = tweedie(link = "log")
)

# make prediction grid:
nd <- replicate_df(qcs_grid, "year", unique(pcod$year))

# Note `return_tmb_object = TRUE` and the prediction grid:
predictions <- predict(m, newdata = nd, return_tmb_object = TRUE)
ind <- get_index(predictions)
#> Bias correction is turned off.
#> It is recommended to turn this on for final inference.

if (require("ggplot2", quietly = TRUE)) {
ggplot(ind, aes(year, est)) + geom_line() +
  geom_ribbon(aes(ymin = lwr, ymax = upr), alpha = 0.4)
}


cog <- get_cog(predictions)
cog
#>    year       est       lwr       upr        se coord
#> 1  2003  463.5260  446.4142  480.6378  8.730670     X
#> 2  2004  476.7402  466.4506  487.0297  5.249871     X
#> 3  2005  470.6887  457.7494  483.6280  6.601796     X
#> 4  2007  480.8948  464.5560  497.2336  8.336280     X
#> 5  2009  477.2029  457.9185  496.4872  9.839144     X
#> 6  2011  470.5112  457.6004  483.4221  6.587284     X
#> 7  2013  471.9877  455.6078  488.3676  8.357252     X
#> 8  2015  463.0289  449.6443  476.4136  6.829028     X
#> 9  2017  470.5219  455.4189  485.6249  7.705734     X
#> 10 2003 5757.8611 5739.8547 5775.8675  9.187109     Y
#> 11 2004 5732.5037 5720.8788 5744.1285  5.931164     Y
#> 12 2005 5763.0315 5750.1526 5775.9104  6.570990     Y
#> 13 2007 5738.2313 5716.8428 5759.6199 10.912733     Y
#> 14 2009 5734.0288 5713.3608 5754.6968 10.545101     Y
#> 15 2011 5747.1037 5733.6282 5760.5792  6.875389     Y
#> 16 2013 5747.6446 5728.9691 5766.3201  9.528488     Y
#> 17 2015 5753.9697 5736.8439 5771.0956  8.737855     Y
#> 18 2017 5755.9728 5739.6443 5772.3014  8.331045     Y
# }