resp_groupwise: Creates Group-Wise Item Response Dataset

View source: R/resp_groupwise.R

resp_groupwiseR Documentation

Creates Group-Wise Item Response Dataset

Description

Creates group-wise item response dataset.

Usage

resp_groupwise(resp, group, items_group)

Arguments

resp

Dataset with item responses

group

Vector of group identifiers

items_group

List containing vectors of groups for each item which should be made group-specific

Value

Dataset

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: Toy dataset
#############################################################################

library(CDM)
library(TAM)

data(data.ex11, package="TAM")
dat <- data.ex11
dat[ dat==9 ] <- 0
resp <- dat[,-1]

# group labels
booklets <- sort( unique(paste(dat$booklet)))

#- fit initial model
mod0 <- TAM::tam.mml( resp, group=dat$booklet)
summary(mod0)

# fit statistics
fmod <- IRT.RMSD(mod)
stat <- abs(fmod$MD[,-1])
stat[ is.na( fmod$RMSD[,2:4] ) ] <- NA
thresh <- .01
round(stat,3)
# define list define groups for group-specific items
items_group <- apply( stat, 1, FUN=function(ll){
                v1 <- booklets[ which( ll > thresh ) ]
                v1[ ! is.na(v1) ]  } )

#- create extended response dataset
dat2 <- sirt::resp_groupwise(resp=resp, group=paste(dat$booklet), items_group=items_group)
colSums( ! is.na(dat2) )

#- fit model for extended response dataset
mod2 <- TAM::tam.mml( dat2, group=dat$booklet)
summary(mod2)

## End(Not run)

sirt documentation built on May 29, 2024, 8:43 a.m.