Skip to contents

select_margin() is a lightweight wrapper around gamlss::fitDist() for the recommended longitudinal workflow: choose a plausible marginal family, then fit dependence with gamlss_longitudinal().

Usage

select_margin(
  response = NULL,
  data = NULL,
  response_var = NULL,
  type = NULL,
  families = NULL,
  time_intercepts = FALSE,
  time_var = NULL,
  try.gamlss = FALSE,
  trace = FALSE,
  ...
)

screen_margin(...)

Arguments

response

Numeric response vector. For the common select_margin(dat, response_var = "y") call, a data frame supplied here is treated as data.

data

Optional data frame containing the response.

response_var

Optional response column name in data.

type

Optional gamlss::fitDist() type. If NULL, a simple heuristic uses "counts" for non-negative integer responses, "realplus" for positive continuous responses, and "realAll" otherwise.

families

Optional character vector used to filter the returned table.

time_intercepts

Logical; if TRUE, rank retained families by a GAMLSS fit with factor time intercepts for each distribution parameter. This is useful for longitudinal screening where the final model is allowed to vary marginal location, scale, or shape over time. Finite-AIC fits are retained even if the temporary GAMLSS fit did not report convergence; check the returned converged column before selecting a final marginal family.

time_var

Optional time column name in data, required when time_intercepts = TRUE.

try.gamlss, trace, ...

Passed to gamlss::fitDist().

Value

A data frame ordered by AIC and class margin_selection. With time_intercepts = TRUE, the table includes a converged column for the temporary time-intercept marginal fit. The selected family is also stored in the "selected" attribute for backward compatibility. Use best_fit() or best_fit_family() to extract the selected family in a fitting-friendly form.