Title: | Classical Test Theory (CTT) Analysis |
---|---|
Description: | Functions for classical test theory analysis, following methods presented by Wu et al. (2006) <doi:10.1007/978-981-10-3302-5>. |
Authors: | Andrés Christiansen [aut, cre] |
Maintainer: | Andrés Christiansen <[email protected]> |
License: | GPL (>= 2.0) |
Version: | 0.7.0 |
Built: | 2024-11-28 06:52:49 UTC |
Source: | CRAN |
Calculates several item and person statistics following
ctitem()
, and ctperson()
.
classicaltest( x, key = NULL, categories = NULL, wt = NULL, listwise = FALSE, recScore = TRUE, administered = NULL )
classicaltest( x, key = NULL, categories = NULL, wt = NULL, listwise = FALSE, recScore = TRUE, administered = NULL )
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 |
categories |
a vector indicating all possible categories.
If |
wt |
a numeric vector of total weights. Default is |
listwise |
only consider complete data (remove rows with NAs).
Defaulft is |
recScore |
a logical value indicating if the total score for
should be calculated based only on valid values. Thus,
if |
administered |
a logical matrix indicating which items where administered.
The dimensions should be the same as |
A list with item and person statistics.
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 and person analysis for multiple choice items classicaltest(x = dichodata, key = dichokey, categories = c('A','B','C','D'), wt = wt) # Item and person analysis for polytomous items classicaltest(x = polydata, key = NULL, wt = wt)
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 and person analysis for multiple choice items classicaltest(x = dichodata, key = dichokey, categories = c('A','B','C','D'), wt = wt) # Item and person analysis for polytomous items classicaltest(x = polydata, key = NULL, wt = wt)
Transforms a data frame or matrix with raw answers into a data frame with 1s (correct answers) and 0s (incorrect answers).
correct(x, key, navalue = NA)
correct(x, key, navalue = NA)
x |
a data frame or matrix. |
key |
a vector indicating the keys to score the data. |
navalue |
a single value indicating the score of NAs. |
A data frame with 1s for correct answers and 0s for incorrect answers.
data(dichodata) data(dichokey) # NAs as NAs head(dichodata) ex1 <- correct(x = dichodata, key = dichokey, navalue = NA) head(ex1) # NAs as 0s head(dichodata) ex2 <- correct(x = dichodata, key = dichokey, navalue = 0) head(ex2)
data(dichodata) data(dichokey) # NAs as NAs head(dichodata) ex1 <- correct(x = dichodata, key = dichokey, navalue = NA) head(ex1) # NAs as 0s head(dichodata) ex2 <- correct(x = dichodata, key = dichokey, navalue = 0) head(ex2)
Calculates several item statistics, including: item mean, frequencies, proportions, valid proportions, and correlations between item responses and the total score.
ctitem( x, key = NULL, categories = NULL, wt = NULL, listwise = FALSE, recScore = TRUE )
ctitem( x, key = NULL, categories = NULL, wt = NULL, listwise = FALSE, recScore = TRUE )
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 |
categories |
a vector indicating all possible categories.
If |
wt |
a numeric vector of total weights. Default is |
listwise |
only consider complete data (remove rows with NAs).
Defaulft is |
recScore |
a logical value indicating if the total score for
should be calculated based only on valid values. Thus,
if |
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.
A data frame with item statistics.
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)
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)
Calculates persons statistics given a data frame (or matrix) of corrected data. Including sum scores, number of administered items, number of answered items, proportion of correct items (for dichotomous data), and mean score by item (for polytomous data).
ctperson(x, administered = NULL)
ctperson(x, administered = NULL)
x |
a data frame or matrix of corrected data (only containing 1s, 0s, and NAs). |
administered |
a logical matrix indicating which items where administered.
The dimensions should be the same as |
A data frame with person statistics.
# Data preparation ## Corrected data corr <- correct(x = dichodata, key = dichokey, navalue = NA) ## Random administered matrix set.seed(1919) admin <- sample(x = 0:1, size = nrow(corr)*ncol(corr), replace = TRUE, prob = c(.05,.95)) admin <- matrix(data = as.logical(admin),nrow = nrow(corr)) head(admin) # Person statistics with all items administered ex1 <- ctperson(x = corr) head(ex1) # Person statistics with NOT all items administered ex2 <- ctperson(x = corr, administered = admin) head(ex2)
# Data preparation ## Corrected data corr <- correct(x = dichodata, key = dichokey, navalue = NA) ## Random administered matrix set.seed(1919) admin <- sample(x = 0:1, size = nrow(corr)*ncol(corr), replace = TRUE, prob = c(.05,.95)) admin <- matrix(data = as.logical(admin),nrow = nrow(corr)) head(admin) # Person statistics with all items administered ex1 <- ctperson(x = corr) head(ex1) # Person statistics with NOT all items administered ex2 <- ctperson(x = corr, administered = admin) head(ex2)
Simulated multiple choice data with 1000 cases, and 20 items
Converts a matrix or data frame into a dichotomized data frame. Where each possible category is assigned a 1 or a 0.
dichotomize(x, id = NULL, categories = NULL, NAasNA = TRUE, sortbyItem = FALSE)
dichotomize(x, id = NULL, categories = NULL, NAasNA = TRUE, sortbyItem = FALSE)
x |
a data frame or matrix. |
id |
a vector of unique values indicating the ids of the cases.
If |
categories |
a vector indicating all possible categories.
If |
NAasNA |
a logical value indicating if NAs should be kept
as NAs. If |
sortbyItem |
a logical value indicating if the resulting data frame
should be order by item names, on the contrary, by ids.
Default is |
A data frame with columns for the ids, the item names and all the possible item categories, where 1s mean the person answered that category for that item, and 0s mean the contrary.
data(dichodata) # Dichotomize with all present categories ex1 <- dichotomize(dichodata, categories = NULL) head(ex1) # Dichotomize with fixed set of categories ex2 <- dichotomize(dichodata, categories = c('A','B','C','D')) head(ex2) # Dichotomize with NAs as 0s ex3 <- dichotomize(dichodata, NAasNA = FALSE) head(ex3)
data(dichodata) # Dichotomize with all present categories ex1 <- dichotomize(dichodata, categories = NULL) head(ex1) # Dichotomize with fixed set of categories ex2 <- dichotomize(dichodata, categories = c('A','B','C','D')) head(ex2) # Dichotomize with NAs as 0s ex3 <- dichotomize(dichodata, NAasNA = FALSE) head(ex3)
Estimates the point-biserial correlation coefficient between dichotomous items and the person's score.
pointbiserial(x, wt = NULL, exclude = FALSE, listwise = FALSE, recScore = TRUE)
pointbiserial(x, wt = NULL, exclude = FALSE, listwise = FALSE, recScore = TRUE)
x |
a numeric data frame or matrix containing only two categories. |
wt |
a numeric vector of total weights. Default is |
exclude |
a logical value indicating if the point-biserial correlation
should be calculated excluding the item from the total score.
Defaulft is |
listwise |
only consider complete data (remove rows with NAs).
Defaulft is |
recScore |
a logical value indicating if the total score for
should be calculated based only on valid values. Thus,
if |
A numeric vector with the point-biserial correlation coefficients by item.
data(dichodata) data(dichokey) # Data preparation ## Corrected data corr <- correct(x = dichodata, key = dichokey, navalue = NA) ## Random weights creation set.seed(1919) wt <- sample(x = 1:4, size = nrow(corr), replace = TRUE) # Correlations without weights pointbiserial(x = corr, wt = NULL) # Correlations with weights pointbiserial(x = corr, wt = wt) # Correlations if item is excluded pointbiserial(x = corr, exclude = TRUE) # Correlations if NAs are considered 0s (recScore) pointbiserial(x = corr, recScore = FALSE) # Correlations with listwise pointbiserial(x = corr, listwise = TRUE)
data(dichodata) data(dichokey) # Data preparation ## Corrected data corr <- correct(x = dichodata, key = dichokey, navalue = NA) ## Random weights creation set.seed(1919) wt <- sample(x = 1:4, size = nrow(corr), replace = TRUE) # Correlations without weights pointbiserial(x = corr, wt = NULL) # Correlations with weights pointbiserial(x = corr, wt = wt) # Correlations if item is excluded pointbiserial(x = corr, exclude = TRUE) # Correlations if NAs are considered 0s (recScore) pointbiserial(x = corr, recScore = FALSE) # Correlations with listwise pointbiserial(x = corr, listwise = TRUE)
Simulated polytomous items data with 1000 cases, and 20 items