View source: R/nl_derivatives.R
| nl_derivatives | R Documentation |
Uses numerical differentiation on the prediction grid to compute the
first derivative (slope / marginal effect), the second derivative
(curvature), and propagated confidence bands for both, using the
delta method from the se.fit column of nl_predict().
Results are passed to nl_turning_points to identify
local turning points and inflection regions.
nl_derivatives(pred_df, x, time = NULL, h = NULL, level = 0.95)
pred_df |
A data frame returned by |
x |
Character; name of the focal predictor column. |
time |
Optional character; name of the time column. If present, derivatives are computed separately within each time level. |
h |
Numeric; step size for finite-difference approximation.
Default |
level |
Confidence level for derivative CIs. Default |
A data frame with columns x (the focal predictor),
time (if applicable), fit (predicted outcome),
d1 (first derivative), d1_lwr and d1_upr
(lower and upper CI for the first derivative), d2 (second
derivative), and d2_lwr and d2_upr (CI for the second
derivative).
nl_turning_points, nl_plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.