·
3 commits
to main
since this release
MultiSpline 0.2.0
Now on CRAN — install.packages("MultiSpline")
This is a major update adding a complete estimation, interpretation, and
diagnostic framework for nonlinear multilevel spline modeling in R.
All v0.1.0 function calls remain valid without modification.
What's new
Cross-classified and nested multilevel structures
Supply two cluster variables and choose cross-classified or nested
random effects:
# Cross-classified
nl_fit(data = df, y = "score", x = "age",
cluster = c("school_id", "student_id"), nested = FALSE)
# Nested (higher-level grouping first)
nl_fit(data = df, y = "score", x = "age",
cluster = c("school_id", "student_id"), nested = TRUE)Automatic knot / df selection
# Standalone diagnostic
nl_knots(data = df, y = "score", x = "age", df_range = 2:8)
# Or inside nl_fit
nl_fit(data = df, y = "score", x = "age", df = "auto")Multilevel R-squared decomposition
nl_r2(fit)
# Returns marginal R2m, conditional R2c, and a full variance
# partition table (r2_mlm style) across all random-effect levelsDerivative-based interpretation
deriv <- nl_derivatives(pred, x = "age") # d1, d2 with CI bands
tp <- nl_turning_points(deriv, x = "age") # maxima, minima, inflections
nl_plot(deriv_df = deriv, x = "age", type = "slope")
nl_plot(deriv_df = deriv, x = "age", type = "curvature")
nl_plot(pred_df = pred, deriv_df = deriv, x = "age", type = "combo")Model comparison workflow
nl_compare(fit, polynomial_degrees = 2:3)
# AIC, BIC, log-likelihood, LRT vs linear for all candidate modelsCluster heterogeneity analysis
nl_het(fit, n_clusters_plot = 30)
# Plots subject BLUPs vs population mean
# LRT: random slopes vs random interceptsAdditional features
- B-spline basis:
method = "bs",bs_degreeargument - Random spline slopes:
random_slope = TRUE - CI for
glmerModvia delta method (default) or bootstrap
(glmer_ci = "boot")
Bug fixes
nl_r2()variance partition no longer produces NA rows in nested modelsnl_predict()CI now correct when controls are character variablesnl_plot()no longer errors when no time column is present
Installation
# From CRAN (recommended)
install.packages("MultiSpline")
# Development version from GitHub
remotes::install_github("causalfragility-lab/MultiSpline")Citation
citation("MultiSpline")Hait, S. (2026). MultiSpline: Spline-Based Nonlinear Modeling for
Multilevel and Longitudinal Data. R package version 0.2.0.
https://CRAN.R-project.org/package=MultiSpline
Full changelog
See [NEWS.md](https://github.com/causalfragility-lab/MultiSpline/blob/main/NEWS.md)