| nl_het | R Documentation |
Quantifies and visualises how much the nonlinear relationship between
x and y varies across clusters, using a model with random
spline slopes.
The function:
Refits the model with random spline slopes (if not already fitted
with random_slope = TRUE).
Extracts cluster-specific predicted curves (BLUPs).
Returns a heterogeneity summary: variance of slopes across clusters at each x value, and a plot of the cluster-specific trajectories.
Performs a likelihood-ratio test comparing the random-slope model against a random-intercept-only model to assess whether heterogeneity is statistically significant.
nl_het(
object,
n_clusters_plot = 30L,
x_seq = NULL,
level = 0.95,
plot = TRUE,
seed = 42L
)
object |
An |
n_clusters_plot |
Maximum number of cluster curves to display in the
trajectory plot. Default |
x_seq |
Optional numeric vector of x values for prediction. |
level |
Confidence level for the population-mean ribbon. Default
|
plot |
Logical; print the trajectory plot. Default |
seed |
Integer seed for reproducibility when sub-sampling clusters.
Default |
A list (invisibly) with:
trajectory_dfLong data frame of cluster-specific predicted values.
slope_varianceNamed numeric: SD of first-derivative estimates across clusters at each x value.
lrtLRT comparing random-slope vs random-intercept model
(NULL if random_slope = TRUE was supplied).
plotA ggplot object.
nl_fit, nl_derivatives
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.