ref_derivative
Usage
ref_derivative( reference, newdata, with_respect_to, centiles = c(0.05, 0.25, 0.5, 0.75, 0.95), h = 0.01, outcomes = NULL)Estimates $\partial Q_t(p)/\partial t$ of the modeled quantile
curves by central finite differences, with a delta-method standard
error from the fitted coefficient covariance (Vp) applied to the
finite-difference of the linear-predictor matrix. This is a
population-chart derivative, not an individual longitudinal estimate.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
reference |
A ref_fit. |
newdata |
Grid of covariate values. |
with_respect_to |
The time covariate, as a bare column name or a string. |
centiles |
Probability levels. |
h |
Finite-difference step. |
outcomes |
Optional subset of outcomes (default: all). |
Details
Section titled “Details”chart_velocity_se is the sampling error of the fitted coefficients.
It does not cover the bias of the spline itself, which is the larger
error whenever the basis of the with_respect_to smooth is too small
to represent the trajectory. That case is detectable – the smooth’s
effective degrees of freedom saturate its basis – so it is warned
about; refit with a larger k and compare.
A ref_derivative tibble with columns .outcome, time,
centile, chart_velocity, and chart_velocity_se (NA when the
engine does not expose a coefficient covariance).
Examples
Section titled “Examples”ref <- ref_simulate(150, seed = 1)fit <- ref_fit(ref_spec(ref_gaussian(), ~ s(age, k = 5) + sex), ref, "y")grid <- data.frame(age = c(30, 50, 70), sex = factor("F", levels = c("F", "M")))ref_derivative(fit, grid, with_respect_to = age, centiles = c(0.1, 0.5, 0.9))# A tibble: 9 × 5 .outcome time centile chart_velocity chart_velocity_se* <chr> <dbl> <dbl> <dbl> <dbl>1 y 30 0.1 0.134 0.02592 y 50 0.1 0.0686 0.01513 y 70 0.1 0.0156 0.02394 y 30 0.5 0.134 0.02595 y 50 0.5 0.0686 0.01516 y 70 0.5 0.0156 0.02397 y 30 0.9 0.134 0.02598 y 50 0.9 0.0686 0.01519 y 70 0.9 0.0156 0.0239