# create a list of parameters (see NRM.sim function)
NUMBI <- 5
ParList <- lapply(1:NUMBI,function(x)
{
Item1 <- c(c(-2,-1,1,2),c(-1.2,0.3,0.2,0.7))
names(Item1) <- c(paste("zeta",1:4,sep=""),paste("lamb",1:4,sep=""))
Item1
})
names(ParList) <- paste("item",1:NUMBI,sep="")
# simulate the data for 2 groups
perp1 <- rnorm(1000,0,1)
perp2 <- rnorm(1000,1,1)
simdat1 <- NRM.sim(ParList,perp1)
simdat2 <- NRM.sim(ParList,perp2)
simdat1 <- data.frame(ID=1:1000,simdat1)
simdat2 <- data.frame(ID=1001:2000,simdat2)
simdatalla <- merge(simdat1,simdat2,all=TRUE)
simdatall <- simdatalla[,-1]
head(simdatall)
gruAB <- factor(rep(c("A","B"),each=1000))
DAT1 <- data.frame(simdatall,ABgroup = gruAB)
head(DAT1)
# reshape the data
reshdat <- reshMG(DAT1,items=1:5,groups=6,correct=rep(0,5), design="nodif")
# DIF design
mydes <- designTemp(ngru= 2, nit= 5, TYPE= "NRM")
mydes$zeta[2,5] <- 2
mydes$lambda[2,5] <- 2
reshdat2 <- reshMG(DAT1,items=1:5,groups=6,correct=rep(0,5), design=mydes)
Run the code above in your browser using DataLab