| check_items | R Documentation |
Real-world item sets often contain columns that break or silently degrade a
factor analysis: an item everyone answered the same way (no variance), an
item dominated by one response with a couple of stray answers, or an item
with heavy missingness. On the polychoric basis these are especially costly
– a near-empty response category can make psych::polychoric() fail
outright (see the correct argument of ackwards()), and a near-constant
item can produce a plausible-looking but meaningless factor with no warning.
check_items() reports these problems before you fit, one row per item, so
you can collapse rare categories, drop degenerate items, or set
cor/correct deliberately rather than debugging a cryptic error. It only
reports; it never changes your data. ackwards() runs the same screen
internally: it errors on a constant item and warns on a
near-degenerate one, naming the offenders.
check_items(data, cor = c("polychoric", "pearson", "spearman"))
data |
A data frame or numeric matrix (items in columns). |
cor |
The correlation basis you plan to use: |
A data frame (class check_items) with one row per item and columns
item, n_valid, pct_missing, n_distinct, min_count (smallest
observed category count), top_prop (proportion of valid responses in the
most common value), and flag – one of "ok", "constant",
"near-constant", "sparse category", or "high missing". Print it for a
grouped summary with guidance; treat it as a plain data frame for the full
per-item table.
ackwards() and its correct argument (the polychoric failure this
screens for); factorability(), suggest_k(), and comparability(), the
other pre-analysis diagnostics.
# sim16 is clean continuous data -> nothing flagged
check_items(sim16, cor = "pearson")
# An item dominated by one response with a couple of stray answers is flagged
d <- sim16
d$bad <- c(rep(1L, nrow(d) - 2L), 2L, 3L)
check_items(d)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.