simulating multilevel data

51 views
Skip to first unread message

Seongho Bae

unread,
Oct 24, 2017, 3:51:16 AM10/24/17
to mirt-package
Hello, all.

I plan to simulate the multilevel data to experiment.

In current, I plan to simulate dichotomous items. However, I do not know how can do that with mirt::simdata() function.

Anyone have an idea for doing this?

Best,
Seongho

Phil Chalmers

unread,
Oct 24, 2017, 6:23:34 AM10/24/17
to Seongho Bae, mirt-package
Hi Seongho,

You can still use simdata, but basically have to nest it within a loop
to condition on the higher-level random effects. The mixedmirt()
helpfile has a few examples of how to do this. HTH.

Phil
> --
> You received this message because you are subscribed to the Google Groups
> "mirt-package" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mirt-package...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Seongho Bae

unread,
Nov 6, 2017, 12:08:09 AM11/6/17
to mirt-package
Hi Phil,

Okay, I saw that. That's very helpful to me. <3

In addition, Can I specify the variance of random clusters in that procedures?

Best,
Seongho

2017년 10월 24일 화요일 오후 7시 23분 34초 UTC+9, Phil Chalmers 님의 말:

Phil Chalmers

unread,
Nov 6, 2017, 1:38:34 PM11/6/17
to Seongho Bae, mirt-package
Sure, something like the following would do it:

sigma_cluster <- 0.5 ## sd of the cluster random effect
N <- 2000
a <- matrix(rep(1,10),10,1)
d <- matrix(rnorm(10))
cluster = 100
random_intercept = rnorm(cluster,0,sigma_cluster)
Theta = numeric()
for (i in 1:cluster)
    Theta <- c(Theta, rnorm(N/cluster,0,1) + random_intercept[i])

group = factor(rep(paste0('G',1:cluster), each = N/cluster))
covdata <- data.frame(group)
dat <- simdata(a,d,N, itemtype = rep('2PL',10), Theta=matrix(Theta))

Phil

To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package+unsubscribe@googlegroups.com.

Seongho Bae

unread,
Nov 25, 2017, 6:34:26 AM11/25/17
to mirt-package
Thanks, Phil! I can understand that a little how to work that.

Hence, I want to know the add another cluster group like treatment, Yes or No in fixed effect term and cross-classified cluster. Can I consider that? I don't have an idea to execute that. Just add new group like this? Too sorry for my poor understanding the LLTM and EMEIRT terminology; I do not learn enough these model in the industrial psychology doctoral coursework. Korean psychometricians do not know well them who I can available to ask.

sigma_cluster_prime = .8
cluster_prime = 200
random_intercept_prime = rnorm(cluster_prime, 0, sigma_cluster_prime)
Theta = numeric()
for (i in 1:cluster) {
 for(j in 1:cluster_prime) {
  Theta <- c(Theta, rnorm(N/cluster, 0, 1) + random_intercept[i])
  Theta <- c(Theta, rnorm(N/cluster_prime, 0, 1) + random_intercept_prime[j])
  Theta <- c(Theta, runif(N))
 }
}

Best,
Seongho

2017년 11월 7일 화요일 오전 3시 38분 34초 UTC+9, Phil Chalmers 님의 말:
Reply all
Reply to author
Forward
0 new messages