Skip to contents

This utility plots every smooth term in a fitted gamlss.longitudinal object and computes pointwise confidence bands using the smooth coefficient covariance matrices returned by vcov.gamlss.longitudinal().

Usage

plot_smooth_terms(
  object,
  vcov_obj = NULL,
  data = NULL,
  ci_level = 0.95,
  ncol = NULL,
  ci_col = "red",
  fit_col = "black",
  ci_lty = 2,
  fit_lwd = 2,
  sort_x = TRUE,
  even_grid = TRUE,
  grid_n = 200,
  fallback_to_index = TRUE,
  setup_mfrow = TRUE,
  show_legend = TRUE
)

Arguments

object

A fitted gamlss.longitudinal object.

vcov_obj

Optional output from vcov(object, ...). If NULL, this is computed internally with the analytical vcov path.

data

Optional data frame containing original covariates used for the x-axis variable of each smooth.

ci_level

Confidence level for pointwise intervals.

ncol

Number of plot columns (defaults to 2 or fewer if needed).

ci_col

Color for confidence bands.

fit_col

Color for fitted smooth line.

ci_lty

Line type for confidence bands.

fit_lwd

Line width for fitted smooth.

sort_x

Logical; sort points by x before plotting lines.

even_grid

Logical; if TRUE, plot smooths on an evenly spaced x-grid built over observed x-range.

grid_n

Number of grid points when even_grid = TRUE.

fallback_to_index

Logical; if x variable cannot be inferred, plot against row index.

setup_mfrow

Logical; if TRUE (default), configure par(mfrow) inside this function. Set FALSE when caller configures layout.

show_legend

Logical; if TRUE, draw a small legend in each panel.

Value

Invisibly returns a nested list with x, fitted values, standard errors, and confidence limits for each smooth term.