View source: R/long-grmtree-threshpar.R
| threshpar_longitudinal_grmtree | R Documentation |
Extracts threshold (difficulty) parameters for each unique item from all terminal nodes of a longitudinal GRM tree. Only T1 item parameters are returned since the constrained model enforces equal thresholds across T1 and T2 within each node.
threshpar_longitudinal_grmtree(object, node = NULL, clean_names = TRUE, ...)
object |
A |
node |
Optional vector of node IDs. If NULL (default), extracts from all terminal nodes. |
clean_names |
Logical. If TRUE (default), clean item names by removing common prefixes (e.g., "resp_wideMOS_") and suffixes (e.g., "_BL", "_T1"). |
... |
Additional arguments (currently unused). |
A data.frame with columns:
Terminal node ID
Item name (cleaned if clean_names = TRUE)
Threshold parameters for each category boundary
Contains n_items rows per node (not 2 * n_items).
longitudinal_grmtree for Phase 1 (tree fitting),
discrpar_longitudinal_grmtree for extracting discrimination
parameters for longitudinal GRMTree,
itempar_longitudinal_grmtree for extracting item parameters
for longitudinal GRMTree
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)
)
# Print the threshold parameters
thresholds <- threshpar_longitudinal_grmtree(ltree)
print(thresholds)
# Using the raw names
threshpar_longitudinal_grmtree(ltree, clean_names = FALSE) # raw names
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.