##### CREATE DATA ###########
x1 <- rnorm(10*5,0,1.7)
zeta <- tapply(x1,rep(1:10,each=5), function(x) round(x - mean(x),3))
# lambda parameters
x2 <- rnorm(10*5,0,1.1)
lam <- tapply(x2,rep(1:10,each=5), function(x)
{
sort(round(x - mean(x),3),decreasing=FALSE)
})
# create a parlist as a first step
ParList <- mapply(function(one,two)
{
x1 <- c(one,two)
names(x1) <- paste0(rep(c("zeta","lam"),each=length(one)),1:length(one))
return(x1)
},one=zeta,two=lam,SIMPLIFY=FALSE)
names(ParList) <- paste0("item",1:length(ParList))
erglist <- vector(mode="list",length=100)
erglistTIME <- vector(mode="list",length=100)
perp1 <- rnorm(6000,0,1)
perp2 <- rnorm(6000,0.3,1)
simdat1 <- NRM.sim(ParList,perp1)
simdat2 <- NRM.sim(ParList,perp2)
simdatall <- rbind(simdat1,simdat2)
simdatallg <- data.frame(GROUP=factor(rep(c("A","B"),each=6000)),simdatall)
##### RESHAPE ###########
my_resh <- reshMG(simdatallg,items=2:11,groups=1,correct=rep(3,10),echo=FALSE)
##### DDF ###########
my_ddf <- DDF(my_resh)
# inspection of some arbitrary chosen item
my_ddf[[1]][[1]]
####### different reference group ##########
# use the level argument to set a different reference group
simdatallg2 <- data.frame(GROUP=factor(rep(c("A","B"),each=6000),levels=c("B","A")),simdatall)
##### RESHAPE ###########
my_resh2 <- reshMG(simdatallg2,items=2:11,groups=1,correct=rep(3,10),echo=FALSE)
##### DDF ###########
my_ddf2 <- DDF(my_resh2)
# inspection of some arbitrary chosen item
my_ddf2[[1]][[1]]
Run the code above in your browser using DataLab