make_test: Creating object representing a test

View source: R/make_test.R

make_testR Documentation

Creating object representing a test

Description

Function makes a list object representing test items given matrices of slopes and intercepts/thresholds parameters. Result may be used within a call to generate_test_responses.

Usage

make_test(
  scoringMatrix,
  slopes,
  intercepts,
  mode = c("irtree", "gpcm"),
  scoringOnPreviousResponses = NULL,
  editResponse = NULL,
  names = paste0("i", 1:nrow(slopes))
)

Arguments

scoringMatrix

a scoring matrix that should be used for items, especially one generated with make_scoring_matrix_aem

slopes

a matrix of slope parameters (items in rows, traits in cols), especially generated with generate_slopes

intercepts

a matrix of intercept parameters (items in rows, intercepts/thresholds in cols), especially generated with generate_intercepts

mode

the way the item should be answered - see generate_item_responses_sqn, generate_item_responses_sml

scoringOnPreviousResponses

an optional function returning a column vector that will be put before first column of the scoringMatrix

editResponse

only if mode='irtree': an optional function returning scoring matrix that should replace that provided by scoringMatrix after response is made at the first node; this should be function accepting two arguments: response - generated response (by the model described with the first column of the scoringMatrix) that is supposed to be edited and scoringMatrix - current scoring matrix (to be replaced)

names

an optional character vector providing names of the items (by default names will be created as concatenation of the letter "i" - like "item" - and consecutive integers)

Details

Function is actually a simple wrapper around make_item - see documentation of this function for further details.

Column names of the intercepts matrix:

  • If mode = "gpcm" names should be of the form: dN where d stands for itself and N are consecutive integers from 1 to one less than the number of rows of the the scoring matrix.

  • If mode = "irtree" names should be of the form: traitN where trait are names of traits - the same as those in columns of the scoring matrix - and N are integers describing consecutive thresholds of a pseudo-item representing the given trait. In the most typical case with binary pseudo-items this should be simply "1" (with in one column for each trait) but polytomous pseudo-items need to be represented by the number of columns less by one than the number of possible responses, with N being consecutive integers.

Value

A list of objects of the rstylesItem class.

Examples

################################################################################
# responses to 10 items using 5-point Likert scale
# with respect to the Bockenholt's IRTree "MAE" model
# 1) make scoring matrix
sM <- make_scoring_matrix_aem(5, "mae")
# 2) generate items' slopes:
# slopes on the 'middle" and "extreme" latent traits set to 1 for all items
# and slopes on the "acquiescence" latent trait generated from a log-normal
# distribution with expected value of about 1.02 and standard deviation of
# about 0.21
slopes <-  cbind(generate_slopes(10, sM[, 1, drop = FALSE], 1),
                 generate_slopes(10, sM[, 2, drop = FALSE], FUN = rlnorm,
                                 meanlog = 0,
                                 sdlog = 0.2),
                 generate_slopes(10, sM[, 3, drop = FALSE], 1))
# 3) generate items' intercepts:
# intercepts generated from the uniform distribution with limits set to
# -1.5 and 1.5
intercepts <- generate_intercepts(10, sM, runif,
                                  list(min = -1.5,
                                       max = 1.5))
# 4) call `make_test()`
# (for IRTree mode must be set accordingly)
test <- make_test(sM, slopes, intercepts, "irtree")

################################################################################
# responses to 20 items using 5-point Likert scale
# with respect to the Plieninger's GPCM (partialy-compensatory) model
# 1) make scoring matrix
sM <- make_scoring_matrix_aem(5, "gpcm")
# 2) generate items' slopes:
# slopes on the 'middle", "extreme" and "acquiescence" latent traits
# set to 1 for all items and slopes on the "intensity" latent trait generated
# from a normal distribution with expected value of 1 and standard deviation
# of 0.3
slopes <-  cbind(generate_slopes(20, sM[, 1, drop = FALSE], FUN = rnorm,
                                 mean = 1, sd = 0.3),
                 generate_slopes(20, sM[, -1], 1))
# 3) generate items' thresholds:
# thresholds generated from the normal distributon of items' (general)
# diificulty wit expected value of 0 and standardo deviation of 1.5 and the
# uniform distribution with limits -1 and 1 of categories' thresholds
# relative to item's difficulty
intercepts <- generate_intercepts(20, sM, FUNd = rnorm, FUNt = runif,
                                  argsd = list(mean = 0, sd = 1.5),
                                  argst = list(min = -1, max = 1))
# 4) call `make_test()`
test <- make_test(sM, slopes, intercepts, "gpcm")

tzoltak/rstyles documentation built on Dec. 4, 2024, 5:16 p.m.