nl_predict: Generate predictions from an nl_fit model

View source: R/nl_predict.R

nl_predictR Documentation

Generate predictions from an nl_fit model

Description

Creates a prediction data frame over a grid of the focal predictor x (and optionally over time), holding control variables at typical values. For mixed models, predictions default to population-level curves (random effects set to zero).

v2 improvements:

  • CI for glmerMod: approximate confidence intervals are computed via the parametric bootstrap or the delta method. Set glmer_ci = "delta" (default, fast) or "boot" (more accurate, slower).

  • Cluster-specific predictions: set re_form = NULL to include random effects in the predictions.

Usage

nl_predict(
  object,
  x_seq = NULL,
  time_levels = NULL,
  controls_fixed = NULL,
  se = TRUE,
  level = 0.95,
  re_form = NA,
  glmer_ci = c("delta", "boot"),
  n_boot = 500L,
  ...
)

Arguments

object

An nl_fit object.

x_seq

Optional numeric vector of x values. If NULL, 200 evenly-spaced points between the 1st and 99th percentiles.

time_levels

Optional vector of time levels.

controls_fixed

Optional named list of fixed control values.

se

Logical; include SEs and CIs. Default TRUE.

level

Confidence level. Default 0.95.

re_form

For mixed models: NA (population-level, default) or NULL (include random effects).

glmer_ci

Method for glmerMod CIs: "delta" (default) or "boot" (parametric bootstrap).

n_boot

Number of bootstrap replicates when glmer_ci = "boot". Default 500.

...

Reserved for future use.

Value

A data frame with columns for the focal predictor, time (if any), controls at fixed values, fit, se.fit, lwr, and upr.

See Also

nl_fit, nl_plot, nl_derivatives


MultiSpline documentation built on April 16, 2026, 9:06 a.m.