Sure. I'm glad you are prepared to help.
library(mirt)
set.seed(12345)
nitems <- 10 # number of items per scale
b2 <- c(-0.8, -0.8, -0.4, -0.4, 0, 0, 0.4, 0.4, 0.8, 0.8)
bc <- b2/4
b1 <- b2 - 1 + sample(bc)
b3 <- b2 + 1 + sample(bc)
a1 <- sample( 1.7+b2/2 )
cf.simb <- as.matrix( data.frame(a1,b1,b2,b3) )
cf.simb <- as.data.frame(cf.simb)
# Transform b-parameters to d-parameters (mirt works with d-parameters)
# difficulty (b) = easiness (d) / -a
cf.sim <- cf.simb
colnames(cf.sim) <- c("a1","d1","d2","d3")
cf.sim$d1 <- -cf.simb$b1*cf.sim$a1
cf.sim$d2 <- -cf.simb$b2*cf.sim$a1
cf.sim$d3 <- -cf.simb$b3*cf.sim$a1
### Simulate dataset using 'mirt'
a1 <- as.matrix(cf.sim[ , 1])
d1 <- as.matrix(cf.sim[ , -1])
# Create theta T1 and dat1 (baseline)
N <- 20000 # sample size
set.seed( sample(10000:20000,1) )
tet1s <- rnorm(N, 0, 1) # simulate theta T1
tet1s <- as.matrix(tet1s)
dat1 <- simdata(a1, d1, N, itemtype="graded", Theta=tet1s)
dat1 <- as.data.frame(dat1)
# Create theta change
tetchs <- rnorm(N, 0.5, 1)
# Create theta T2 and dat2 (follow-up)
tet2s <- as.matrix(tet1s + tetchs) # theta T2
# mean(tet2s)
# var(tet2s)
set.seed( sample(30000:40000,1) )
dat2 <- simdata(a1, d1, N, itemtype="graded", Theta=tet2s)
dat2 <- as.data.frame(dat2)
datw <- data.frame(dat1, dat2)