Abstract

TMB is an open source R package that enables quick implementation of complex nonlinear random effect (latent variable) models in a manner similar to the established AD Model Builder package (ADMB, admb-project.org). In addition, it offers easy access to parallel computations. The user defines the joint likelihood for the data and the random effects as a C++ template function, while all the other operations are done in R; e.g., reading in the data. The package evaluates and maximizes the Laplace approximation of the marginal likelihood where the random effects are automatically integrated out. This approximation, and its derivatives, are obtained using automatic differentiation (up to order three) of the joint likelihood. The computations are designed to be fast for problems with many random effects (~10^6) and parameters (~10^3). Computation times using ADMB and TMB are compared on a suite of examples ranging from simple models to large spatial models where the random effects are a Gaussian random field. Speedups ranging from 1.5 to about 100 are obtained with increasing gains for large problems. The package and examples are available at http://tmb-project.org.

Highlights

  • Calculation of derivatives plays an important role in computational statistics

  • The case studies “ar1_4D” and “ar1xar1” would be hard to implement in ADMB because the sparsity would have to be manually represented instead of automatically detected

  • This paper describes TMB, a fast and flexible R package for fitting models both with and without random effects

Read more

Summary

Introduction

Calculation of derivatives plays an important role in computational statistics. One classic application is optimizing an objective function; e.g., maximum likelihood estimation. Higher order derivatives calculated using AD greatly facilitate optimization of the Laplace approximation for the marginal likelihood in complex models with random effects; e.g., Skaug and Fournier (2006). This approach, implemented in the ADMB and TMB packages, has been used to fit simple random effects models as well as models containing Gaussian Markov random fields (GMRF). The TMB package is built around the same principles, but rather than being coded more or less from scratch, it combines several existing high-performance libraries, to be specific, CppAD for automatic differentiation in C++, Matrix (Bates and Maechler 2015) for sparse and dense matrix calculations in R, Eigen for sparse and dense matrix calculations in C++, and OpenMP for parallelization in C++ and Fortran.

The Laplace approximation
AD and CppAD
Software implementation
Inverse subset algorithm
Automatic sparsity detection
Parallel Cholesky through BLAS
Parallel user templates using OpenMP
Using the TMB package
Case studies
Results
Discussion
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call