ctitem: Classical test theory item statistics

View source: R/ctitem.R

ctitemR Documentation

Classical test theory item statistics

Description

Calculates several item statistics, including: item mean, frequencies, proportions, valid proportions, and correlations between item responses and the total score.

Usage

ctitem(
  x,
  key = NULL,
  categories = NULL,
  wt = NULL,
  listwise = FALSE,
  recScore = TRUE
)

Arguments

x

a data frame or matrix. For multiple choice items, columns can be numeric or strings and keys should be provided. For polytomous items, all columns should be numeric.

key

a vector indicating the keys to score the data. If NULL items are assumed as polytomous. Default is NULL.

categories

a vector indicating all possible categories. If NULL, this vector will be created with all the non-NA values present in x. Default is NULL.

wt

a numeric vector of total weights. Default is NULL.

listwise

only consider complete data (remove rows with NAs). Defaulft is FALSE.

recScore

a logical value indicating if the total score for should be calculated based only on valid values. Thus, if TRUE: rowMeans(x,na.rm = TRUE)*apply(x,1L,function(k) sum(!is.na(k))); if FALSE: rowMeans(x,na.rm = TRUE)*ncol(x). Defaulft is TRUE. If listwise, this argument is meaningless.

Details

If keys are provided, items are assume as dichotomous and transformed into 1s and 0s, where 1s are correct answers. Then, point-biserial correlations are estimated between the item and the total score (PBtotal), the item and the score without the item (PBrest), between each response category and the total score.

If keys are not provided, data must be numeric, items are assumed as polytomous and data will not be transformed. For polytomous, Pearson's correlations are estimated between the item and the total score (PEtotal), the item and the score without the item (PErest), between each response category and the total score.

Value

A data frame with item statistics.

Examples

data(dichodata)
data(polydata)
data(dichokey)

# Data preparation
## Random weights creation
set.seed(1919)
wt <- sample(x = 1:4, size = nrow(dichodata), replace = TRUE)

# Item analysis for multiple choice items
ctitem(x = dichodata, key = dichokey, categories = c('A','B','C','D'), wt = wt)

# Item analysis for polytomous items
ctitem(x = polydata, key = NULL, wt = wt)


classicaltest documentation built on Oct. 28, 2024, 5:06 p.m.