| RMdimResidualPCA | R Documentation |
Fits a Rasch model by CML via psychotools (a dichotomous item is a
2-category PCM), extracts the standardized residuals (x - E)/\sqrt{Var}
at WLE person locations, and runs an unrotated principal-component
analysis on those residuals via stats::prcomp(). The function reports
the top n_components eigenvalues and their proportions of unexplained
variance, and optionally compares the first-contrast eigenvalue against
a simulation-based bound from RMdimResidualPCACutoff.
RMdimResidualPCA(
data,
cutoff = NULL,
p_value = FALSE,
n_components = 5L,
output = "kable"
)
data |
A data.frame or matrix of item responses. Items must be scored
starting at 0 (non-negative integers). Rows with any |
cutoff |
Optional. The list returned by |
p_value |
Logical. When |
n_components |
Integer. Number of eigenvalues to report. Capped at the
number of items. Default |
output |
Character. |
Rule-of-thumb thresholds for the first-contrast eigenvalue (e.g., the
"> 2" heuristic occasionally cited from Winsteps documentation) are not
reliable indicators of multidimensionality; the first-contrast eigenvalue
under a correctly fitting unidimensional model varies systematically with
sample size, test length, and item-parameter spread. Empirical (simulated)
bounds tailored to the data structure should be used instead — see
RMdimResidualPCACutoff, and Chou & Wang (2010) for the underlying
simulation argument.
The PCA is performed on the standardized residuals
(x - E)/\sqrt{Var} from the shared CML/WLE engine (CML item
parameters via psychotools, WLE person locations). The reported
eigenvalues are unrotated; rotation is appropriate for interpreting a
multidimensional solution but obscures the dominant first contrast that
dimensionality assessment is concerned with.
Item locations on the loadings plot are the per-item mean of the CML Andrich thresholds.
The variance partition follows Linacre's convention: per-item observed variance is compared to per-item expected variance under the fitted model, summed across items. Expected scores are computed from the CML item parameters and WLE person locations. WLE is finite at extreme scores, so all persons are retained (the previous MLE partition dropped extreme-score cases).
Bootstrap p-value. When p_value = TRUE, the observed
first-contrast eigenvalue is compared against the simulated null
distribution of largest eigenvalues (from cutoff$results), giving the
one-sided Monte-Carlo p-value (1 + #\{lambda* >= lambda\}) / (B + 1).
Because the maximum eigenvalue is a single family-wise statistic, no
multiplicity correction applies. The p-value is model-conditional and
sample-size-sensitive; it is reported alongside the simulated cutoff, not
in place of it, and can be no smaller than 1 / (B + 1).
If output = "kable": a knitr_kable object with columns Component,
Eigenvalue, Proportion of variance (and Flagged when cutoff is
provided; p when p_value = TRUE). The caption gives the variance
partition (% of total observed variance explained by measures vs.
unexplained), the model fitted, sample size, and cutoff/p-value metadata
if applicable.
If output = "dataframe": a data.frame with columns Component,
Eigenvalue, Proportion_of_variance (and Flagged when cutoff is
provided; p when p_value = TRUE, non-NA for PC1 only). The
variance partition is attached as the
"variance_partition" attribute — a list with elements total,
explained, unexplained, pct_explained, pct_unexplained,
n_persons. Access via
attr(result, "variance_partition").
If output = "ggplot": a ggplot showing each item's PC1 loading on
the x-axis and Rasch item location on the y-axis, with dashed reference
lines at zero, and the variance partition in the figure caption. Item
names are labelled via ggrepel::geom_text_repel() when ggrepel is
installed; otherwise plain geom_text().
Chou, Y.-T., & Wang, W.-C. (2010). Checking dimensionality in item response models with principal component analysis on standardized residuals. Educational and Psychological Measurement, 70(5), 717-731. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1177/0013164410379322")}
RMdimResidualPCACutoff
set.seed(1)
dat <- as.data.frame(
matrix(sample(0:1, 200 * 12, replace = TRUE), nrow = 200, ncol = 12)
)
colnames(dat) <- paste0("I", 1:12)
# Default kable output
RMdimResidualPCA(dat)
# PC1 loadings vs item location plot
if (requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("ggrepel", quietly = TRUE)) {
RMdimResidualPCA(dat, output = "ggplot")
}
# Simulation-based cutoff (use 250+ iterations in real analyses)
bound <- RMdimResidualPCACutoff(dat, iterations = 50, parallel = FALSE, seed = 1)
RMdimResidualPCA(dat, cutoff = bound)
# With the one-sided bootstrap p-value for the first contrast
RMdimResidualPCA(dat, cutoff = bound, p_value = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.