collapse_W {eRm}R Documentation

Convenient Collapsing of LLRA Design Matrix


Collapses columns of a design matrix for LLRA to specify different parameter restrictions in LLRA.


collapse_W(W, listItems, newNames)



A design matrix (for LLRA), typically from a call to build_W or component $W from LLRA or LPCM


A list of numeric vectors. Each component of the list specifies columns to be collapsed together.


An (optional) character vector specifying the names of the collapsed effects.


This function is a convenience function to collapse a design matrix, i.e. to specify linear trend or treatment effects and so on. Collapsing here means that effects in columns are summed up. For this, a list of numeric vectors with the column indices of columns to be collapsed have to be passed to the function. For example, if you want to collapse column 3, 6 and 8 into one new effect and 1, 4 and 9 into another it needs to be passed with list(c(3,6,8),c(1,4,9)).

The new effects can be given names by passing a character vector to the function with equal length as the list.


An LLRA design matrix as described by Hatzinger and Rusch (2009). This can be passed as the W argument to LLRA or LPCM.


Thomas Rusch


Hatzinger, R. and Rusch, T. (2009) IRT models with relaxed assumptions in eRm: A manual-like instruction. Psychology Science Quarterly, 51, pp. 87–120.

See Also

The function to build design matrices from scratch, build_W.


##An LLRA with 2 treatment groups and 1 baseline group, 5 items and 4
##time points. Item 1 is dichotomous, all others have 3, 4, 5, 6
##categories respectively.    
llraDat2a <- matrix(unlist(llraDat2[1:20]),ncol=4)
groupvec <-rep(1:3*5,each=20)
W <- build_W(llraDat2a, nitems=5, mpoints=4, grp_n=c(10,20,40), groupvec=groupvec,itmgrps=1:5)

#There are 55 parameters to be estimated

#Imposing a linear trend for the second item ,i.e. parameters in
#columns 32, 37  and 42 need to be collapsed into a single column. 
collItems1 <- list(c(32,37,42))
newNames1 <- c("trend.I2")
Wstar1 <- collapse_W(W,collItems1)

#53 parameters need to be estimated

[Package eRm version 1.0-2 Index]