How to incorporate a and b correlation into 2PL model data generation

Hello,
My 2PL model data generation is as below

twopl.sim <- function( nitem = 200, npers = 2688 ) {
i.loc <- item_b1
p.loc <- rnorm( npers )
i.slp <- item_a1
temp <- matrix( rep( p.loc, length( i.loc ) ), ncol = length( i.loc ) )
logits <- t( apply( temp , 1, '-', i.loc) )
logits <- t( apply( logits, 1, '*', i.slp) )

probabilities <- 1 / ( 1 + exp( -logits ) )
resp.prob <- matrix( probabilities, ncol = nitem)
obs.resp <- matrix( sapply( c(resp.prob), rbinom, n = 1, size = 1), ncol = length(i.loc) )

output <- list()
output$i.loc <- i.loc
output$i.slp <- i.slp
output$p.loc <- p.loc
output$resp <- obs.resp

output
}

In the code above, i.loc is b parameter, i.slp is a parameter, i want the following information to be incorporated in the code above

image

Thank you for any help!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.