View source: R/item.distract.R
| item.distract | R Documentation |
This function conducts distractor analysis for multiple-choice test items, i.e., computes attractor-distractor selection frequency, percentage, and total point-biserial or biserial correlation.
item.distract(data, ..., key, exclude = NULL, na.keep = FALSE, correct = TRUE,
method = c("pbiser", "biser"), ml = FALSE,
print = c("all", "nUQ", "key", "n", "perc", "r"),
color = "default", style = c("regular", "bold", "italic"),
na.omit = FALSE, digits = 1, r.digits = 3, as.na = NULL,
write = NULL, append = TRUE, check = TRUE, output = TRUE)
data |
a data frame. Note that missing values should be represented
with |
... |
an expression indicating the variable names in |
key |
a numeric or character vector of the answer key with a length
matching the number of variables specified in the argument
|
exclude |
a character vector indicating items to be excluded from the analysis. |
na.keep |
logical: if |
correct |
logical: if |
method |
a character string indicating which correlation coefficient
is used for the item-total correlation, i.e., |
ml |
logical: if |
print |
a character vector indicating which results to print, i.e.,
|
color |
a character string indicating the text color for highlighting
the attractor frequency, percentage, and attractor-total
correlation, , i.e., |
style |
a character vector indicating the font style, i.e.,
|
na.omit |
logical: if |
digits |
an integer value indicating the number of decimal places to be used to display descriptive statistics, e.g., mean, median, and standard deviation. |
r.digits |
an integer value indicating the number of decimal places to be used to display the item difficulty, item-total correlation, and the coefficient alpha if the item is deleted. |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
write |
a character string naming a file for writing the output into
either a text file with file extension |
append |
logical: if |
check |
logical: if |
output |
logical: if |
Returns an object of class misty.object, which is a list with following
entries:
call |
function call |
type |
type of analysis |
data |
data frame including all variables used in the analysis |
key |
list with the answer key and the position of the answer key for each item |
args |
specification of function arguments |
result |
result table |
This function uses a modified copy of the polyserial() function in the
polycor package by John Fox when requesting distractor-total biserial
correlation.
Takuya Yanagida
Fox, J. (2025). polycor: Polychoric and polyserial correlations. R package version 0.8-2. https://doi.org/10.32614/CRAN.package.polycor
item.stats, item.alpha, item.omega,
item.cfa, item.reverse, item.scores
## Not run:
#————————————————————————————————————————————————————————————————————————————
# Multiple-Choice Items
# Answer key
key <- c("D", "B", "C", "C", "B", "B", "B", "A", "A", "D")
# Example 1a: Corrected distractor-total point-biserial correlation
item.distract(data.items, +mitem, key = key)
# Example 1b: Corrected distractor-total biserial correlation
item.distract(data.items, +mitem, key = key, method = "biser")
# Example 1c: Keep missing values, i.e., do not convert NA into 0
item.distract(data.items, +mitem, key = key, na.keep = TRUE)
# Example 1d: Print corrected distractor-total point-biserial correlation only
item.distract(data.items, +mitem, key = key, print = "r")
# Example 1e: Highlight attractor frequency, percentage, and correlation in bright red
item.distract(data.items, +mitem, key = key, na.keep = TRUE, color = "b.red")
# Example 1f: Highlight attractor frequency, percentage, and correlation in boldface
item.distract(data.items, +mitem, key = key, na.keep = TRUE, color = "black",
style = "bold")
#————————————————————————————————————————————————————————————————————————————
# Write Results
# Example 2a: Write Results into a text file
item.distract(data.items, +mitem, key = key, write = "Item-Distract.txt", output = FALSE)
# Example 2b: Write Results into an Excel file
item.distract(data.items, +mitem, key = key, write = "Item-Distracts.xlsx", output = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.