Wraps a user-defined latent block (currently a tgmrf() object) so the
formula parser can recognise and route it to the inference layer. The
call is structural – it is never executed at fit time. The parser
evaluates the inner expression in the formula's environment, removes
the latent(...) term from the fixed-effects formula, and attaches the
resulting object to parsed$latent_blocks.
Arguments
- block
A tgmrf (or, in the future, tgeneric) object.
Value
Returns block invisibly. Outside a formula context the call is
a no-op pass-through.
Examples
n <- 8
blk <- tgmrf(
Q = function(theta) Matrix::Diagonal(n, exp(-2 * theta[1])),
prior = function(theta) stats::dnorm(theta[1], 0, 1, log = TRUE),
init = c(log_sigma = 0))
parsed <- tulpa_parse_formula(y ~ x + latent(blk))
parsed$n_latent_blocks