gllvmTMB 0.2.0 (first CRAN release)
First public release of gllvmTMB, a Template Model Builder (TMB) engine for stacked-trait generalised linear latent variable models (GLLVMs). gllvmTMB() fits multivariate models in which the same observational units carry several responses – traits, species, items, behaviours, outcomes – and the scientific question concerns their shared latent covariance, ordination, communality, phylogenetic signal, or spatial structure.
User-facing API
-
Two entry points share one long-format engine:
-
gllvmTMB(value ~ ..., data = df_long, unit = "...")accepts long-format data (one row per(unit, trait)observation) and wide data frames marked with the formula-LHS helpertraits(...). The wide form uses compact syntax such astraits(t1, t2, t3) ~ 1 + latent(1 | unit, d = 2); the parser expands fixed predictors,latent()/unique()/indep()/dep(), bar-stylephylo_indep()/phylo_dep(), andspatial_*()terms to the long trait-stacked grammar. Species-axisphylo_scalar()/phylo_unique()/phylo_latent()calls and ordinary(1 | group)random intercepts pass through unchanged. -
gllvmTMB_wide(Y, ...)is the matrix-in entry point for matrix-first workflows and the only path that accepts per-cell weight matrices.
-
-
The covariance grammar is a 3 x 5 keyword grid (correlation x mode):
correlation mode scalar unique indep dep latent none (omit) unique()indep()dep()latent()phylo phylo_scalar()phylo_unique()phylo_indep()phylo_dep()phylo_latent()spatial spatial_scalar()spatial_unique()spatial_indep()spatial_dep()spatial_latent()The decomposition mode pairs
latent + unique:Sigma = Lambda Lambda^T + diag(s). Per-trait response families: gaussian, binomial (with multi-trial via
cbind(succ, fail)or weights), betabinomial, poisson, lognormal, Gamma, nbinom2, tweedie, Beta, student, ordinal_probit, truncated_poisson, truncated_nbinom2, delta_lognormal, delta_gamma. Mixed-family fits are accepted viafamily = list(...)keyed by trait.gllvmTMB()requires at least one covariance-structure term. A call without anylatent()/unique()/indep()/dep()/phylo_*()/spatial_*()term errors with a pointer toglmmTMB::glmmTMB()for single-response work.New technical reference articles cover the covariance keyword grid, the response-family surface, and the ordinal-probit threshold scale and cutpoint convention.
Inference
- ML or REML point estimates via TMB’s Laplace approximation.
- Profile-likelihood confidence intervals for derived quantities (repeatability, communality, phylogenetic signal, pairwise correlations) through the
profile_ci_*()family. -
extract_correlations()exposes Fisher-z (default), Wald, and bootstrap intervals via themethodargument.
Phylogenetic and spatial paths
- Phylogenetic covariance via the sparse
A^-1representation of Hadfield & Nakagawa (2010), withtree(anape::phylo) orphylo_vcv = Cphy(a precomputed covariance matrix) as input. - Spatial covariance via the SPDE / GMRF approximation from
sdmTMB.gllvmTMBincludes SPDE / mesh / anisotropy helpers (make_mesh(),R/crs.R, parts ofR/plot.R) inherited fromsdmTMBunder GPL-3; provenance is recorded ininst/COPYRIGHTSand at the top of each inherited R file.
Inherited code and citation
Authors@Rnames Shinichi Nakagawa as the sole author ofgllvmTMB. Upstream copyright holders for inherited code (Anderson, Ward, English, Barnett forsdmTMBSPDE / mesh / anisotropy R helpers; Kristensen forTMB; Thorson forVASTtransitively viasdmTMB) are recorded ininst/COPYRIGHTSand acknowledged ininst/CITATION,README.md, and file-top comments of the inherited R files. This follows the CRAN-recommended pattern in “Writing R Extensions” §1.1.1 of using aCopyright: inst/COPYRIGHTSfield rather thancphentries inAuthors@Rfor inherited-code copyright holders.inst/CITATIONcuratescitation("gllvmTMB"). The primary entry is the (in-prep) Nakagawa methods paper; companion entries cite Kristensen et al. (2016) for TMB and Anderson et al. (2025) forsdmTMBwhen the spatial path is used.
Source-tree notes
- The TMB engine is compiled at install time from
src/gllvmTMB.cpp. The DLL is registered viauseDynLib(gllvmTMB, .registration = TRUE). -
gllvmTMBcontrol()returns an options object distinct fromsdmTMB::sdmTMBcontrol(). Extra...arguments emit a warning.
Relationship to a pre-0.2.0 development line
The pre-0.2.0 development line of gllvmTMB re-exported a large surface from sdmTMB and exposed single-response paths; the 0.2.0 release does neither. Users who want single-response models should install sdmTMB or glmmTMB directly, which install side-by-side with gllvmTMB without conflict.
