View source: R/rs_characterize_plots.R
| plot_rs_tree | R Documentation |
Displays the Longitudinal GRMTree structure with RS characterization results annotated in each terminal node panel. Each panel shows the omnibus test result, latent trait parameters, and an item-level RS heatmap color-coded by RS type.
plot_rs_tree(
tree,
rs,
item_labels = NULL,
tnex = 2.5,
drop_terminal = TRUE,
...
)
tree |
A |
rs |
An |
item_labels |
Optional character vector of short item labels. If NULL, uses "Item 1", "Item 2", etc. |
tnex |
Numeric scaling factor for terminal node panels (default: 2.5). |
drop_terminal |
Logical (default: TRUE). |
... |
Additional arguments passed to |
Each terminal node panel contains:
Omnibus RS result: chi-squared, adjusted p-value, and detection status
Latent parameters: mean shift at T2 and test-retest correlation (mu_T2 and cor(T1,T2)
Item-level RS bar: colored cells for each item indicating RS type (blue = recalibration, orange = reprioritization, purple = both, gray = none)
Invisibly returns the tree object.
library(grmtree)
# Load the synthetic longitudinal data
data("grmtree_long_data", package = "grmtree")
# Prepare the wide-format response matrix
items_t1 <- c("MOS_Listen", "MOS_Info", "MOS_Advice_Crisis", "MOS_Confide",
"MOS_Advice_Want", "MOS_Fears", "MOS_Personal", "MOS_Understand")
ld <- prepare_longitudinal_data(
data = grmtree_long_data,
items_t1 = items_t1,
items_t2 = paste0(items_t1, "_year1"),
covariates = c("sex", "age", "residency", "job",
"education", "comorbidity_count", "ever_smoker")
)
# Phase 1: fit the longitudinal GRM tree
ltree <- longitudinal_grmtree(
resp_wide ~ sex + age + residency + job +
education + comorbidity_count + ever_smoker,
data = ld, n_items = 8,
control = grmtree.control(minbucket = 200)
)
# Phase 2: characterize response shift within each subgroup
rs <- rs_characterize(ltree, p_adjust = "fdr",
global_p_adjust = "bonferroni")
# Plot the rs tree
plot_rs_tree(ltree, rs,
item_labels = c("Listen", "Info", "Crisis",
"Confide", "Advice", "Fears",
"Personal", "Understand"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.