I have some trouble about setting constraints on the testlet model. I will be very thankful if you can answer my question.
The testlet model equation that I use is the following:
g(\pi_j)= a_{jg}(\theta_g + C_k\theta_k) +d_j
Now I want to simulate a dataset with 12 items. Every four items share the same testlet effects, and their item discriminations on the secondary dimension should be a_jg*Ck. When I use the constrain command to define this relationship, it keeps giving the same error message: "CONSTRAIN = ... indexed a parameter that was not relevant for item 1."
I have pasted my codes below:
set.seed(1234)
a <- matrix(0, 12, 4)
a[,1] <- rlnorm(12, 0.2, 0.3)
ind <- 1
for(i in 1:3){
a[ind:(ind+3),i+1] <- rep(rlnorm(1,0.2,0.3),4)
ind <- ind+4
}
print(a) #the first column refers to a_jg, the remaining columns are C_k.
#We need to do some transformations to get the item discrimination matrix.
a[,2:4]<-a[,2:4]*a[,1] #a_jg*C_k
print(a)
d <- rnorm(12, 0, .5)
sigma <- diag(c(1, .5, 1, .5))
dataset <- simdata(a,d,2000,itemtype=rep('2PL', 12),sigma=sigma)
specific <- c(rep(1,4),rep(2,4), rep(3,4))
#constrain Items 1-4 has the same testlet effect. Do the same thing
#for Items 5-8, and Items 9-12.
model <- 'G = 1-12
#I want to define Ck would be the same
CONSTRAIN = (1-4, a2/a1), (5-8,a3/a1),(9-12,a4/a1)
COV = S1*S1, S2*S2, S3*S3'
tlmirt <- bfactor(dataset, specific, model)
I appreciate your time!
Best,
Jiaying