Implementing neural network mixed-effects models in Template Model Builder (TMB)

Nan Zheng, Hoi Yiu Cheung, Vibhu Sharma, James T. Thorson, Noel G. Cadigan
8/31/2026
stat.MLcs.LG

No confident code implementation found for this paper.

Abstract

Neural network mixed-effects models (NMMs) have gained traction by combining the strong representation and predictive power of artificial neural networks with the capacity of mixed-effects modeling to capture complex correlation structures. However, existing estimation approaches rely heavily on manual derivations of objective functions and gradients, which inherently forces simplifying approximations and severely constrains the complexity and accuracy of NMMs.

Show full abstract

In this work, we introduce a general framework for implementing NMMs using Template Model Builder (TMB). By leveraging automatic differentiation and Laplace approximation, TMB requires users to specify only the negative joint log-likelihood and any regularization terms. The framework automatically integrates out random effects and evaluates the marginal objective function alongside its exact gradients, eliminating the need for manual derivations or ad hoc approximations. We demonstrate the efficiency, flexibility, and statistical performance of TMB-based NMMs across two numerical examples, including an application to monotonic NMMs. Reproducible code is provided to facilitate broader adoption.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{zheng2026implementing,
  title  = {Implementing neural network mixed-effects models in Template Model Builder (TMB)},
  author = {Nan Zheng and Hoi Yiu Cheung and Vibhu Sharma and James T. Thorson and Noel G. Cadigan},
  year   = {2026},
  eprint = {2608.31133},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2608.31133v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2608.31133.svg)](https://codeofpaper.com/paper/2608.31133)

Discussion