Learn R Programming

rstyles (version 0.4.0)

score_on_last_answer_straight: Graphical patterns in careless/inattentive responding

Description

Functions that allows to model careless/inattentive responding in a form of creating various graphical patterns of responses:

  • score_on_last_answer_straight - straightlining, i.e. tendency to choose the same answer as in the previous item;

  • score_on_last_answer_next - tendency to choose answer that is directly to the right side/below of the answer to the previous item; if there are no answers farther right/below, than turn to the first (most left/top) available answer;

  • score_on_last_answer_previous - tendency to choose answer that is directly to the left side/up of the answer to the previous item; if there are no answers farther left/up, than turn to the last (most right/bottom) available answer;

  • score_on_previous_answers_bounce - tendency to choose answer that is either directly to the right side/below or directly to the left side/up of the answer to the previous item in such a way to continue a pattern of the last two responses; if there are no more answers in a given direction, than change direction (bounce).

Usage

score_on_last_answer_straight(previousResponses, scoringMatrix)

score_on_last_answer_next(previousResponses, scoringMatrix)

score_on_last_answer_previous(previousResponses, scoringMatrix)

score_on_previous_answers_bounce(previousResponses, scoringMatrix)

Arguments

previousResponses

character vector of previous responses

scoringMatrix

matrix describing how responses (described in rownames of the matrix) map on scores of latent traits (described in columns of the matrix)

Value

one-column matrix of 0 and 1 with the same number of rows (and rownames) as scoringMatrix with column name ci

Examples

Run this code
# NOT RUN {
sM <- make_scoring_matrix_aem(1:5, "simultaneous")


answersStraigth <- t(sapply(c(1:5, rep(3, 5)), score_on_last_answer_straight,
                            scoringMatrix = sM))
dimnames(answersStraigth) <- list(paste0("previous answer: '",
                                         c(1:5, rep(3, 5)), "'"),
                                  paste0("'", 1:ncol(answersStraigth), "'"))
answersStraigth

answersNext <- t(sapply(rep(1:5, 2), score_on_last_answer_next,
                        scoringMatrix = sM))
dimnames(answersNext) <- list(paste0("previous answer: '",
                                     1:nrow(answersNext), "'"),
                              paste0("'", 1:ncol(answersNext), "'"))
answersNext

answersPrev <- t(sapply(rep(1:5, 2), score_on_last_answer_previous,
                        scoringMatrix = sM))
dimnames(answersPrev) <- list(paste0("previous answer: '",
                                     1:nrow(answersPrev), "'"),
                              paste0("'", 1:ncol(answersNext), "'"))
answersPrev

bounceMatrix <- matrix(c(3:1, 2:5, 4:2, 2:1, 2:5, 4:1), ncol = 2)
answersBounce <- t(apply(bounceMatrix, 1, score_on_previous_answers_bounce,
                         scoringMatrix = sM))
dimnames(answersBounce) <- list(paste0("previous answers: '",
                                       apply(bounceMatrix, 1, paste,
                                             collapse = "', '"), "'"),
                                paste0("'", 1:ncol(answersBounce), "'"))
answersBounce
# }

Run the code above in your browser using DataLab