Skip to contents

Creates a data frame of discrete item responses based on.

Usage

response_gen(
  subject,
  item,
  theta,
  a_par = NULL,
  b_par,
  c_par = NULL,
  d_par = NULL,
  item_no = NULL,
  ogive = "Logistic"
)

Arguments

subject

integer vector of test taker IDs.

item

integer vector of item IDs.

theta

numeric vector of latent test taker abilities.

a_par

numeric vector of item a parameters for each item.

b_par

numeric vector of item b parameters for each item.

c_par

numeric vector of item c parameters for each item.

d_par

list of numeric vectors of item threshold parameters for each item.

item_no

vector of item numbers the correspond the item parameters

ogive

can be "Normal" or "Logistic".

Details

subject and item must be equal lengths.

Generalized partial credit models (!is.null(d_par)) uses threshold parameterization.

Examples

set.seed(1234)
s_id <- c(
  1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4,
  4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7,
  7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10,
  10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
  13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
  16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 19, 19,
  19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20
)
i_id <- c(
  1, 4, 7, 10, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 1, 4, 7, 10, 3, 6, 9, 1, 4,
  7, 10, 3, 6, 9, 1, 4, 7, 10, 3, 6, 9, 2, 5, 8, 3, 6, 9, 1, 4, 7, 10, 2,
  5, 8, 2, 5, 8, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 1, 4, 7, 10, 3, 6, 9, 2,
  5, 8, 3, 6, 9, 1, 4, 7, 10, 3, 6, 9, 2, 5, 8, 3, 6, 9, 2, 5, 8, 3, 6, 9,
  2, 5, 8, 3, 6, 9, 2, 5, 8, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 1, 4, 7, 10,
  2, 5, 8, 1, 4, 7, 10, 2, 5, 8, 1, 4, 7, 10, 3, 6, 9
)
bb <- c(-1.72, -1.85, 0.98, 0.07, 1.00, 0.13, -0.43, -0.29, 0.86, 1.26)
aa <- c(1.28, 0.78, 0.98, 1.21, 0.83, 1.01, 0.92, 0.76, 0.88, 1.11)
cc <- rep(0, 10)
dd <- list(
  c(0, 0, -0.13, 0, -0.19, 0, 0, 0, 0, 0),
  c(0, 0, 0.13, 0, 0.19, 0, 0, 0, 0, 0)
)
response_gen(
  subject = s_id, item = i_id, theta = rnorm(20, 0, 1),
  b_par = bb, a_par = aa, c_par = cc, d_par = dd
)
#>    i001 i002 i003 i004 i005 i006 i007 i008 i009 i010 subject
#> 1     1   NA    0    0   NA    0    0   NA    0    0       1
#> 2     1    1   NA    1    1   NA    0    1   NA    0       2
#> 3     1   NA    1    1   NA    0    1   NA    0    1       3
#> 4     0   NA    0    0   NA    0    0   NA    0    0       4
#> 5     1   NA    0    1   NA    0    1   NA    0    1       5
#> 6    NA    1    0   NA    0    0   NA    1    1   NA       6
#> 7     1    0   NA    0    0   NA    1    0   NA    0       7
#> 8    NA    1    1   NA    1    0   NA    0    0   NA       8
#> 9     1    1   NA    0    1   NA    0    0   NA    0       9
#> 10    1   NA    0    0   NA    0    0   NA    0    0      10
#> 11   NA    1    0   NA    0    1   NA    1    0   NA      11
#> 12    1   NA    0    1   NA    1    1   NA    0    0      12
#> 13   NA    0    0   NA    2    0   NA    1    0   NA      13
#> 14   NA    1    2   NA    0    1   NA    1    0   NA      14
#> 15   NA    1    2   NA    2    1   NA    1    0   NA      15
#> 16   NA    0    0   NA    0    0   NA    0    0   NA      16
#> 17    1    1   NA    1    0   NA    1    0   NA    1      17
#> 18    1    1   NA    1    2   NA    0    0   NA    1      18
#> 19    1    1   NA    0    0   NA    0    1   NA    0      19
#> 20    1   NA    1    1   NA    1    1   NA    1    1      20