% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dummy_expand.R
\name{dummy_expand}
\alias{dummy_expand}
\title{Dummmy Expantion of Categorical Data}
\usage{
dummy_expand(Uc, ncat = NULL, type = NULL, zero = 1)
}
\arguments{
\item{Uc}{Item Response matrix in Compressed Format}

\item{ncat}{a vector consisting of # of categories of each item}

\item{type}{NOT used.}

\item{zero}{= 0 to exclude the zero-th category from output}
}
\value{
A list of \cr
U, ncat, type, zero, fromP, toP
}
\description{
Dummmy Expantion of Categorical Data
}
\details{
In compressed format, Uc[i,j]=k means that subject i answers to item j
 by selecting option k, k=0,1,...,ncat[j]. \cr
 This function expands this compressed format to uncompressed
 dummy expanded format: \cr
 That is, each item takes ncat[j] colums of U[, fromP[j]:toP[j]], \cr
 and the k+fromP[j]-th colum will be 1, and 0 elsewhere.
}
\examples{
# generate item response
# in uncompressed format
# set.seed(1701)
# res <- gendataIRT( 1, paramS1, npoints=7, thmin=-3, thmax=3 )
# U=res$U
# in compressed format
# set.seed(1701)
# res1 <- gendataIRT( 1, paramS1, npoints=7, thmin=-3, thmax=3, compress=1 )
# Uc=res1$U
#
# uncompressed data: ncat=c(2,2,4)
U <- "
Q1_0 Q1_1 Q2_0 Q2_1 Q3_0 Q3_1 Q3_2 Q3_3
1    0    1    0    1    0    0    0   
1    0    1    0    0    1    0    0   
1    0    1    0    1    0    0    0   
1    0    1    0    0    1    0    0   
1    0    0    1    0    0    1    0   
0    1    0    1    0    0    0    1   
0    1    0    1    0    0    0    1   
"; U=cards( U, header=1 )
#
# compressed data: ncat=c(2,2,4)
Uc <- "
 Q1 Q2 Q3
 0  0  0 
 0  0  1 
 0  0  0 
 0  0  1 
 0  1  2 
 1  1  3 
 1  1  3 
"; Uc=cards( Uc, header=1 )


# from compressed to uncompressed
U1=dummy_expand(Uc)$U
# back to compressed
Uc1=dummy_compress(U)$Uc
Print(U-U1)
Print(Uc-Uc1)

# zero=0 option
U2=dummy_expand(Uc, zero=0)$U
Uc2=dummy_compress(U2, zero=0, ncat=c(2,2,4))$Uc
Print(Uc-Uc2)


}
