Learn R Programming

immer (version 1.5-13)

immer_proc_data: Processing Datasets and Creating Design Matrices for Rating Data

Description

The function immer_proc_data processes datasets containing rating data into a dataset into a long format of pseudoitems (item \(\times\) raters).

The function immer_create_design_matrix_formula creates a design matrix for a processed dataset and a provided formula.

Usage

immer_proc_data(dat, pid=NULL, rater=NULL, weights=NULL, maxK=NULL)

immer_create_design_matrix_formula( itemtable, formulaA )

Value

The output of immer_proc_data is a list with several entries (selection)

dat2

Dataset containing pseudoitems

dat2.resp

Dataset containing response indicators for pseudoitems

dat2.NA

Dataset containing pseudoitems and missing responses coded as NA

dat

Original dataset

person.index

Person identifiers

rater.index

Rater identifiers

VV

Number of items

N

Number of persons

RR

Number of raters

dat2.ind.resp

Array containing indicators of pseudoitems and categories

ND

Number of person-rater interactions

itemtable

Information about processed data

The output of immer_create_design_matrix_formula is a list with several entries (selection)

A

design matrix

itemtable2

Processed item table

Arguments

dat

Datasets with integer item responses

pid

Vector with person identifiers

rater

Vector with rater identifiers

weights

Vector with sampling weights

maxK

Optional vector with maximum category per item

itemtable

Processed item table. The table must include the column item (an integer item identifier) and maxK (maximum number of categories per item). Optional columns are rater (an integer rater identifier),item_name and rater_name.

formulaA

An R formula. The facets item, step and rater are treated as numeric. However, numeric transformation can be applied for the step parameter by using the arguments item_num, step_num or rater_num in formulaA.

Examples

Run this code
#############################################################################
# EXAMPLE 1: Processing rating data
#############################################################################

data(data.immer01a, package="immer")
dat <- data.immer01a

res <- immer::immer_proc_data( dat=dat[,paste0("k",1:5)], pid=dat$idstud,
             rater=dat$rater)
str(res, max.level=1)

if (FALSE) {
#############################################################################
# EXAMPLE 2: Creating several design matrices for rating data
#############################################################################

data(data.ratings1, package="sirt")
dat <- data.ratings1
resp <- dat[,-c(1,2)]
#- redefine the second and third item such that the maximum category score is 2
for (vv in c(2,3)){
    resp[ resp[,vv] >=2,vv ] <- 2
}

#--- process data
res0 <- immer::immer_proc_data( dat=resp, pid=dat$idstud,  rater=dat$rater)

#--- rating scale model
des1 <- immer::immer_create_design_matrix_formula( itemtable=res0$itemtable,
                formulaA=~ item + step )
des1$des

#--- partial scale model
des2 <- immer::immer_create_design_matrix_formula( itemtable=res0$itemtable,
                formulaA=~ item + item:step )
des2$des

#--- multi-facets Rasch model
des3 <- immer::immer_create_design_matrix_formula( itemtable=res0$itemtable,
                formulaA=~ item + item:step + rater )
des3$des

#--- polytomous model with quadratic step effects
des4 <- immer::immer_create_design_matrix_formula( itemtable=res0$itemtable,
                formulaA=~ item + item:I(step_num^2) )
des4$des
}

Run the code above in your browser using DataLab