| nl_compare | R Documentation |
Compares a nonlinear spline model against simpler alternatives—a linear model and optional polynomial terms—to help researchers justify the spline approach over simpler specifications.
For each model, the function reports:
AIC and BIC
Log-likelihood (and likelihood-ratio test versus the linear model where available)
Number of parameters (df)
Residual variance / deviance
nl_compare(
object,
polynomial_degrees = c(2L, 3L),
digits = 3L,
return_models = FALSE
)
object |
An |
polynomial_degrees |
Integer vector of polynomial degrees to include
as additional comparators. Default |
digits |
Integer; decimal places for the output table. Default |
return_models |
Logical; if |
A list (invisibly) of class "nl_compare" with:
tableA data frame with the comparison statistics.
modelsNamed list of fitted models (when
return_models = TRUE).
bestName of the model with the lowest AIC.
The table is pretty-printed automatically.
nl_fit, nl_knots
## Not run:
fit <- nl_fit(data = mydata, y = "score", x = "age", df = 4)
nl_compare(fit)
nl_compare(fit, polynomial_degrees = c(2, 3, 4))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.