File: collapse_W.Rd

package info (click to toggle)
r-cran-erm 1.0-6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,952 kB
  • sloc: f90: 401; ansic: 103; makefile: 8
file content (72 lines) | stat: -rwxr-xr-x 2,422 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
\encoding{UTF-8}
\name{collapse_W}
\alias{collapse_W}

\title{
Convenient Collapsing of LLRA Design Matrix 
}
\description{
Collapses columns of a design matrix for LLRA to specify different
parameter restrictions in \code{LLRA}.    
}
\usage{
collapse_W(W, listItems, newNames)
}
\arguments{
  \item{W}{A design matrix (for LLRA), typically from a call to
    \code{\link{build_W}} or component \code{$W} from \code{\link{LLRA}}
    or \code{\link{LPCM}}
  } 
  \item{listItems}{A list of numeric vectors. Each component of the list specifies
    columns to be collapsed together. 
  }
  \item{newNames}{An (optional) character vector specifying the names of
    the collapsed effects. 
  }
}
\details{
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 \code{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. 
}

\value{An LLRA design matrix as described by Hatzinger and Rusch
  (2009). This can be passed as the \code{W} argument to \code{LLRA} or
 \code{LPCM}.
}
\references{
Hatzinger, R. and Rusch, T. (2009) IRT models with relaxed assumptions
in eRm: A manual-like instruction. \emph{Psychology Science Quarterly},
  \bold{51}, pp. 87--120.
}
\author{Thomas Rusch}
\seealso{
The function to build design matrices from scratch, \code{\link{build_W}}.
}
\examples{
##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
dim(W)

#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
dim(Wstar1)
}