Learn R Programming

guess (version 0.7.0)

multi_transmat: Creates a transition matrix for each item.

Description

Needs an 'interleaved' dataframe (see interleave function). Pre-test item should be followed by corresponding post-item item etc. Don't knows may be coded as d/DK or, by default, NA. Function handles items without don't know responses. The function is used internally. It calls transmat.

Usage

multi_transmat(
  pre_test = NULL,
  pst_test = NULL,
  subgroup = NULL,
  force9 = FALSE,
  agg = FALSE,
  na_as = c("dk", "missing"),
  missing_action = c("omit", "error")
)

Value

matrix with rows = total number of items + 1 (last row contains aggregate distribution across items) number of columns = 4 when no don't know, and 9 when there is a don't know option

Arguments

pre_test

Required. data.frame carrying responses to pre-test questions.

pst_test

Required. data.frame carrying responses to post-test questions.

subgroup

a Boolean vector identifying the subset. Default is NULL.

force9

Optional. There are cases where DK data doesn't have DK. But we need the entire matrix. By default it is FALSE.

agg

Optional. Boolean. Whether or not to add a row of aggregate transitions at the end of the matrix. Default is FALSE.

na_as

Classification of NA responses: `"dk"` (the default) treats them as observed don't know responses; `"missing"` treats them as structural missingness.

missing_action

How to handle structural missingness: `"omit"` excludes incomplete pairs and `"error"` rejects them.

Details

multi_transmat: transition matrix of all the items

Examples

Run this code
pre_test <- data.frame(pre_item1 = c(1, 0, 0, 1, 0), pre_item2 = c(1, NA, 0, 1, 0))
pst_test <- data.frame(
  pst_item1 = pre_test[, 1] + c(0, 1, 1, 0, 0),
  pst_item2 = pre_test[, 2] + c(0, 1, 0, 0, 1)
)
multi_transmat(pre_test, pst_test)

Run the code above in your browser using DataLab