plot.GNPC: Plot Diagnostics for GNPC

View source: R/plot.R

plot.GNPCR Documentation

Plot Diagnostics for GNPC

Description

This function gives two types of diagnostic plots for the outcomes of the GNPC algorithm.

The type = "convergence" option gives two graphs: The upper panel displays the trajectory of the proportion of membership switches and the lower panel shows the total squared distance along with the iterations. They illustrate the detailed information about how and whether the algorithm has converged.

The type = "individual" option returns a sequence of squared distances for a single examinee and the estimates of the examinee's attribute profile along with the iterations. The plots allow users to investigate how the algorithm arrives at its final classifications. In simulation studies, the true attribute profile can be provided as a reference.

Usage

## S3 method for class 'GNPC'
plot(
  x,
  type = c("convergence", "individual"),
  examinee.id = NULL,
  true.alpha = NULL,
  top.n.pattern = NULL,
  ...
)

Arguments

x

An object of class "GNPC" when track.convergence = TRUE.

type

"convergence" (default) for overall convergence diagnostics, or "individual" for a single examinee's estimation trajectory.

examinee.id

An integer indicating which examinee to be plotted. This argument is required if "individual" is specified.

true.alpha

A numeric vector of length K when the true attribute profile of the examinee is available (optional; usually used for simulation studies).

top.n.pattern

An integer specifying the maximum number of patterns to be displayed. The default is min(2^K, 6). The GNPC estimate and true pattern (if provided) are always included.

...

Additional arguments passed to plot.

Details

For "individual" plots, the visual elements are:

  • Red line: the attribute pattern ultimately selected by GNPC.

  • Black line: the true attribute pattern (only when true.alpha is provided). A small vertical jitter is applied when it overlaps with the red line.

  • Other colored lines: the most competitive candidate patterns, selected by proximity at the final iteration.

  • Filled circle at each iteration: indicates which attribute profile GNPC assigned to the examinee at each iteration, drawn in the corresponding line's color. The line for the true attribute profile always has black circles at every iteration as a fixed reference.

See Also

GNPC

Examples

## Not run: 
library(GDINA)
set.seed(123)
N <- 500
Q <- sim30GDINA$simQ
gs <- data.frame(guess = rep(0.2, nrow(Q)), slip = rep(0.2, nrow(Q)))
sim <- simGDINA(N, Q, gs.parm = gs, model = "DINA")
Y <- extract(sim, what = "dat")
alpha <- extract(sim, what = "attribute")

# Analyze data using GNPC
result <- GNPC(Y, Q, initial.dis = "hamming", initial.gate = "AND")

# Convergence
plot(result)

# Individual with true attribute profile (simulation)
plot(result, type = "individual", examinee.id = 1, true.alpha = alpha[1, ])

# Individual without true attribute profile (real data)
plot(result, type = "individual", examinee.id = 1)

## End(Not run)


NPCDTools documentation built on Sept. 1, 2026, 1:08 a.m.