Skip to contents

marginal_parameters() averages predicted distributional parameters over fitted rows or a supplied newdata grid. It is a simple plug-in summary layer built on predict_parameters(), intended for interpretation tables and future emmeans-style marginalisation or plotting helpers.

Usage

marginal_parameters(object, ...)

# S3 method for class 'drmTMB'
marginal_parameters(
  object,
  newdata = NULL,
  dpar = NULL,
  by = NULL,
  type = c("response", "link"),
  ...
)

Arguments

object

A drmTMB fit.

...

Reserved for future options.

newdata

Optional data frame for prediction. If omitted, fitted rows are used.

dpar

Optional character vector of distributional parameters to summarise, including fitted random-effect scale model names such as "sd(id)". NULL summarises all fitted distributional parameters.

by

Optional character vector of columns in newdata used to define marginal groups. NULL averages over all prediction rows for each distributional parameter.

type

Prediction scale: "response" or "link".

Value

A data frame with one row per distributional parameter and grouping combination. The returned columns are dpar, component, type, optional by columns, estimate, n, conf.status, and interval_source.

Details

This helper does not compute uncertainty, contrasts, or profile intervals. It reports unweighted averages of already-predicted parameter values. For population-level summaries, supply an explicit newdata grid; with newdata = NULL, the fitted-row prediction contract is the same as predict.drmTMB().

The returned table carries the same interval provenance columns as predict_parameters(). In this first contract, marginal summaries are point estimates with conf.status = "not_requested" and interval_source = "not_available".

Examples

dat <- data.frame(
  y = c(0.2, 0.5, 1.1, 1.4, 1.8, 2.2),
  x = c(-1, -0.5, 0, 0.5, 1, 1.5),
  habitat = factor(rep(c("reef", "sand"), each = 3))
)
fit <- drmTMB(bf(y ~ x + habitat, sigma ~ x), data = dat)
grid <- expand.grid(
  x = c(0, 1),
  habitat = levels(dat$habitat)
)
marginal_parameters(fit, newdata = grid, dpar = c("mu", "sigma"), by = "habitat")
#>    dpar            component     type habitat     estimate n   conf.status
#> 1    mu             location response    reef 1.4986162355 2 not_requested
#> 2    mu             location response    sand 1.4000000355 2 not_requested
#> 3 sigma distributional-scale response    reef 0.0003875289 2 not_requested
#> 4 sigma distributional-scale response    sand 0.0003875289 2 not_requested
#>   interval_source
#> 1   not_available
#> 2   not_available
#> 3   not_available
#> 4   not_available