make_TIRT_data: Prepare data for Thurstonian IRT models

Description Usage Arguments Value Examples

View source: R/data-helpers.R

Description

Prepare data for Thurstonian IRT models

Usage

1
2
3
make_TIRT_data(data, blocks, direction = c("larger", "smaller"),
  format = c("ranks", "pairwise"), family = "bernoulli",
  partial = FALSE, range = c(0, 1))

Arguments

data

An object of class data.frame containing data of all variables used in the model.

blocks

Object of class TIRTblocks generated by set_block indicating which items belong to which block, trait and more. Ignored if data already contains information on the blocks.

direction

Indicates if "larger" (the default) or "smaller" input values are considered as indicating the favored answer.

format

Format of the item responses. Either "ranks" for responses in ranked format or "pairwise" for responses in pairwise comparison format. If "ranks", each item must have its own column in the data frame which contains its ranks within the block. If "pairwise", each existing item combination must have its own column named after the combination of the two compared items.

family

Name of assumed the response distribution. Either "bernoulli", "cumulative", or "gaussian".

partial

A flag to indicate whether partial comparisons are allowed for responses stored in the "ranks" format.

range

Numeric vector of length two giving the range of the responses when using the "pairwise" format. Defaults to c(0, 1) for use with dichotomous responses.

Value

A data.frame in a specific format and with attributes ready for use with other functions of the ThurstonianIRT package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# load the data
data("triplets")

# define the blocks of items
blocks <-
  set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"),
          signs = c(1, 1, 1)) +
  set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"),
            signs = c(-1, 1, 1)) +
  set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"),
            signs = c(1, 1, -1)) +
  set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"),
            signs = c(1, -1, 1))

# generate the data to be understood by 'thurstonianIRT'
triplets_long <- make_TIRT_data(
  data = triplets, blocks = blocks, direction = "larger",
  format = "pairwise", family = "bernoulli", range = c(0, 1)
)


# fit the data using Stan
fit <- fit_TIRT_stan(triplets_long, chains = 1)
print(fit)
predict(fit)

thurstonianIRT documentation built on Aug. 9, 2019, 5:07 p.m.