knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )

Automatic item generation (AIG) is an old concept which was first introduced by John R. Bormuth (1969). This process has not been advanced that much in past few decades. Due to recent demand of test items and high costs in item development, this process has become in light of many educators and psychometricians again.

**QAIG** is an effort to provide tool by means of R function for generating group of dissimilar sibling items from **Quantitative Multiple-Choice** type parent item model. When we think about generating sibling items from a parent item, main focus becomes to have:

- generated items that look dissimilar to each other as much as possible.
- effective distractors in each of the items.

**QAIG** package enables users to generate large number of items from a parent item:

- by applying possible dissimilarities within the sibling items.
- by taking care of effectiveness of the distractors for each sibling item.

`itemgen()`

function and its arguments.**QAIG** package includes a function called `itemgen`

:

`itemgen(stem_text = stem_text, formulae = formulae, N = N, C, ans_key, options_affix, save.csv)`

The usage of this function is illustrated here.

**For stem_text:** User of this package should construct a parent item model i.e. a

`[]`

. Character variable should be written as `[C1], [C2], [C3] … etc.`

. Number variables should be written as `[N1], [N2], [N3] … etc.`

.**For N and C:** For each of the number variables (

`[N1], [N2], [N3], …`

) in the `n1, n2, n3, …`

respectively. Vectors of characters `c1, c2, c3, …`

for each character variable should also be declared similar way. All the `list`

separately as the inputs for `N`

and `C`

in `itemgen()`

function.**For formulae:** A generic

`n1, n2, n3, …`

) of `formulae`

in `itemgen()`

function. The correct response choice should be marked by "~" and distractors should be marked by "?" in the **Note:** User must have *stem text*, *formulae* and the `list`

of *input number vector(s)* to work with `itemgen()`

function, as `stem_text`

, `formulae`

and `N`

are the three default arguments in this function.

```{R include = TRUE} library(QAIG)

```{R echo = TRUE} stem_text <- "What is the sum of first [N1] [C1] ?" n1 <- c(5, 8, 11, 14, 17) c1 <- c("natural numbers", "non-zero positive integers") N <- list(n1 = n1) C <- list(c1 = c1) formulae <- "Option_A ? 2*n1-1 Option_B ? 3*n1-2 Option_C ~ n1*(n1+1)/2 Option_D ? n1*(n1-1)/2 " ## itemgen() function can be used as: newitems <- QAIG::itemgen(stem_text = stem_text, formulae = formulae, N = N, C = C) newitems

`options_affix`

argument.Suffix or prefix or both can be attached with the numeric values in the response choices by using `options_affix`

argument of `itemgen()`

function. Response choice names in `formulae`

and in `options_affix`

must be same. If user wants to declare difficulty level of the item, that also can be added within `options_affix`

.

```{R include = TRUE} library(QAIG)

```{R echo = TRUE} stem_text <- "[C1] has $ [N1] and [C2] has $ [N2] . If [C2] takes $ [N3] from [C1] later, then how much more amount than [C1] does [C3] have now?" c1 <- c('Sam', 'Sean') c2 <- c('Max', 'Martha', 'Mandy') c3 <- c('he', 'she', 'she') n1 <- c(4, 5, 6, 7) n2 <- c(8, 9, 10) n3 <- c(2, 3) C <- list(c1 = c1, c2 = c2, c3 = c3) N <- list(n1 = n1, n2 = n2, n3 = n3) formulae <- "Option_A ? (n1 + n2) Option_B ~ (n2 + 2*n3 - n1) Option_C ? (n1 + n2 + 1) Option_D ? (n1 + n2 - 2) Option_E ? (n2 + n3 - n1) " options_affix <- list(Option_A = c('$ ', ''), Option_B = c('$ ', ''), Option_C = c('$ ', ''), Option_D = c('$ ', ''), Option_E = c('$ ', ''), Difficulty = 'EASY') ## itemgen() function can be used as: newitems <- QAIG::itemgen(stem_text = stem_text, formulae = formulae, N = N, C = C, options_affix = options_affix) newitems[, c(1, 4, 21, 24)]

`options_affix`

.```{R include = TRUE} library(QAIG)

```{R echo = TRUE} stem_text <- "[C1] bought a [C2] at $ [N1] . [C3] spent $ [N2] for repairing it and then sold it at $ [N3] . What was [C4] percentage of profit or loss?" c1 <- c('Samuel', 'April') c2 <- c('motorcycle', 'moped') c3 <- c('He', 'She') c4 <- c('his', 'her') n1 <- c(925, 862, 784) n2 <- c(92, 102) n3 <- 1030 C <- list(c1 = c1, c2 = c2, c3 = c3, c4 = c4) N <- list(n1 = n1, n2 = n2, n3 = n3) formulae <- "Option_A ? round((n2/n1)*100, 2) Option_B ? round(((n3-n2-n1)/n3)*100, 1) Option_C ? round(((n3-n2-n1+0)/n3)*100, 1) Option_D ~ round((((n3-n2-n1)/(n1+n2))*100), 2) " options_affix <- list(Option_A = c('', '% loss'), Option_B = c('', '% profit'), Option_C = c('', '% loss'), Option_D = c('', '% profit'), Option_E = 'No profit no loss') ## itemgen() function can be used as: newitems <- QAIG::itemgen(stem_text = stem_text, formulae = formulae, C = C, N = N, options_affix = options_affix) newitems[, c(1, 2, 3, 6)]

`ans_key`

argument.Answer key of the items can be declared using `ans_key`

argument also. In case of any text response choice becomes the answer key, user should declare the answer key using `ans_key`

argument. In this case all the response choices in `formulae`

must be marked by “?” only.

```{R include = TRUE} library(QAIG)

```{R echo = TRUE} stem_text <- "A [C1] was delayed somewhere for [N1] minutes but made up for the delay on a section of [N2] km travelling at a speed of [N3] km per hour higher than that which accorded the schedule. What was the speed of the [C1] that accorded the schedule?" c1 <- c('car', 'bus', 'truck', 'train') n1 <- c(16, 18, 20, 22, 24) n2 <- c(80, 90, 100, 110) n3 <- c(10, 12, 15, 18) C <- list(c1 = c1) N <- list(n1 = n1, n2 = n2, n3 = n3) formulae <- "p <- 1 Option_A ? round((-n3 + sqrt(n3^2 - 4*p*(-60*n2*n3/n1)))/2,2) Option_B ? round((-n3 - sqrt(n3^2 - 4*p*(-60*n2*n3/n1)))*(-1)/2-20,2) Option_C ? round((-n3 - sqrt(n3^2 - 4*p*(-60*n2*n3/n1)))*(-1)/2,2) Option_D ? round((-n3 + sqrt(n3^2 - 4*p*(-60*n2*n3/n1)))/2+30,2) " options_affix <- list(Option_A = c('', ' km/hr'), Option_B = c('', ' km/hr'), Option_C = c('', ' km/hr'), Option_D = c('', ' km/hr'), Option_E = 'Cannot be determined', Difficulty = 'HARD') ## itemgen() function can be used as: newitems <- QAIG::itemgen(stem_text = stem_text, formulae = formulae, N = N, C = C, ans_key = 'Option_A', options_affix = options_affix) newitems[, c(1, 2, 79, 80)]

`formulae`

.User may want to provide supporting values or a self-defined function to use during formulation of the response choice models. Those can be supplied within `formulae`

by writing in separate lines.

**Note:** Formulation of each response choice model (formula) in `formulae`

must produce a single numeric value.

```{R include = TRUE} library(QAIG)

```{R echo = TRUE} stem_text <- "Sum of present ages of [C1] and [C2] [C3] is [N1] . After [N2] years [C2] [C3] will be thrice as old as [C1] . The present age of [C2] [C3] is" n1 <- c(74, 80, 72, 68) n2 <- c(8, 10) c1 <- c('Sophia', 'Viktor', 'Julia', 'Andy') c2 <- c('her', 'his') c3 <- c('father', 'mother') N <- list(n1 = n1, n2 = n2) C <- list(c1 = c1, c2 = c2, c3 = c3) formulae <- "a <- 5 sol <- function(x, y){ A <- matrix(c(1, 1, 1, -3), nrow=2) B <- matrix(c(x, 2*y), nrow=2) return((as.matrix(solve(A)%*%B))) } Option_A ? round(sol(n1, n2)[1,]+a, 2) Option_B ? round(sol(n1, n2)[2,]+a, 2) Option_C ~ round(sol(n1, n2)[1,], 2) Option_D ? round(sol(n1, n2)[2,], 2) Option_E ? round(sol(n1, n2)[1,]-a, 2) " options_affix <- list(Option_A = c('', ' years'), Option_B = c('', ' years'), Option_C = c('', ' years'), Option_D = c('', ' years'), Option_E = c('', ' years'), Difficulty = 'MEDIUM') ## itemgen() function can be used as: newitems <- QAIG::itemgen(stem_text = stem_text, formulae = formulae, N = N, C = C, options_affix = options_affix) newitems[, c(1, 2, 7, 8)]

`save.csv`

argumentGenerated items can be saved in a `.csv`

file by using the `save.csv`

argument. If a name of the file is passed to this argument, all the generated items will be saved automatically in `.csv`

format in the working directory.

As example:

`itemgen(stem_text, formulae, N, C = C, options_affix = options_affix, save.csv = 'New Items')`

Reference: AIG for Developing Mathematics Achievement Items

**Any scripts or data that you put into this service are public.**

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.