% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rs_characterize_plots.R
\name{plot_rs_tree}
\alias{plot_rs_tree}
\title{Plot Response Shift Summary Tree}
\usage{
plot_rs_tree(
  tree,
  rs,
  item_labels = NULL,
  tnex = 2.5,
  drop_terminal = TRUE,
  ...
)
}
\arguments{
\item{tree}{A \code{longitudinal_grmtree} object.}

\item{rs}{An \code{rs_characterization} object from
\code{\link{rs_characterize}}.}

\item{item_labels}{Optional character vector of short item labels.
If NULL, uses "Item 1", "Item 2", etc.}

\item{tnex}{Numeric scaling factor for terminal node panels (default: 2.5).}

\item{drop_terminal}{Logical (default: TRUE).}

\item{...}{Additional arguments passed to \code{plot.modelparty}.}
}
\value{
Invisibly returns the tree object.
}
\description{
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.
}
\details{
Each terminal node panel contains:
\itemize{
\item Omnibus RS result: chi-squared, adjusted p-value, and detection
status
\item Latent parameters: mu_T2 and cor(T1,T2)
\item Item-level RS bar: colored cells for each item indicating RS type
(blue = recalibration, red = reprioritization, purple = both,
orange = significant small effect, gray = none/not tested)
}
}
\examples{
\dontshow{if (interactive()) withAutoprint(\{ # examplesIf}
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_rs_tree(ltree, rs,
    item_labels = c("Listen", "Info", "Crisis", "Confide",
      "Advice", "Fears", "Personal", "Understand"))
\dontshow{\}) # examplesIf}
}
