simulateCardData: Simulate Card Sorting Data

View source: R/simulateCardData.R

simulateCardDataR Documentation

Simulate Card Sorting Data

Description

This function simulates card sorting data based on user-specified parameters, such as the number of sorters, the probability of correct sorting, and the weights for different card attributes.

Usage

simulateCardData(
  nSorters = 40,
  pCorrect = 0.95,
  attributeWeights = c(1, 1, 1, 1),
  verbose = TRUE
)

Arguments

nSorters

An integer specifying the number of sorters to simulate. Default is 40.

pCorrect

A numeric value between 0 and 1 specifying the probability that a card is sorted correctly. Default is 0.95.

attributeWeights

A numeric vector of length 4 specifying the weights for the card attributes (e.g., color, suit, rank_picture, and odd_even_picture). Default is c(1, 1, 1, 1).

verbose

Logical, if TRUE, additional information about the processing steps is printed to the console.

Details

The function simulates a card sorting experiment where cards are sorted by multiple sorters based on one of four attributes. The probability of sorting a card correctly is determined by pCorrect, and errors are introduced randomly for each sorter. The attribute weights determine how many sorters focus on each attribute, and a warning is issued if the weights do not align with the total number of sorters.

The function returns a data frame containing simulated card sorting data for all sorters, including sorter IDs, card IDs, and assigned stacks.

Value

A data frame with columns:

sorterID

A unique identifier for each sorter.

statement

The ID of the card being sorted.

stackID

The stack assigned to the card by the sorter.

See Also

rbinom, sample

Examples

# Simulate data with default parameters:
set.seed(1)
myCMData <- simulateCardData()

# Simulate data with custom parameters:
set.seed(1)
myCMData <- simulateCardData(nSorters=40, pCorrect=.90, attributeWeights=c(1,1,1,1))


cmAnalysis documentation built on April 4, 2025, 4:27 a.m.