# \donttest{
# Create sample DAG structure with different rank levels
# Format: From, To, Rank
DAG_dat <- matrix(c(
"From", "To", "Rank",
"Item01", "Item02", "1", # Simple structure for Rank 1
"Item01", "Item02", "2", # More complex structure for Rank 2
"Item02", "Item03", "2",
"Item01", "Item02", "3", # Additional connections for Rank 3
"Item02", "Item03", "3",
"Item03", "Item04", "3"
), ncol = 3, byrow = TRUE)
# Method 1: Directly use graph and adjacency lists
g_list <- list()
adj_list <- list()
for (i in 1:3) {
adj_R <- DAG_dat[DAG_dat[, 3] == as.character(i), 1:2, drop = FALSE]
g_tmp <- igraph::graph_from_data_frame(
d = data.frame(
From = adj_R[, 1],
To = adj_R[, 2]
),
directed = TRUE
)
adj_tmp <- igraph::as_adjacency_matrix(g_tmp)
g_list[[i]] <- g_tmp
adj_list[[i]] <- adj_tmp
}
# Fit Local Dependence Latent Rank Analysis
result.LDLRA1 <- LDLRA(J12S5000,
ncls = 3,
g_list = g_list,
adj_list = adj_list
)
# Plot Item Reference Profiles (IRP) in a 4x3 grid
# Shows the probability patterns of correct responses for each item across ranks
plot(result.LDLRA1, type = "IRP", nc = 4, nr = 3)
# Plot Test Reference Profile (TRP)
# Displays the overall pattern of correct response probabilities across ranks
plot(result.LDLRA1, type = "TRP")
# Plot Latent Rank Distribution (LRD)
# Shows the distribution of students across different ranks
plot(result.LDLRA1, type = "LRD")
# }
Run the code above in your browser using DataLab