I've read a number of posts (e.g. this one and this one) in which the author simulates clustered data (some agents $n$ are allocated across clusters $c$, with errors correlated within clusters but not between clusters) by sampling from a multivariate normal distribution.

But then I see posts like this one in which the author specifies an ICC and creates clustered data simply by drawing from univariate normals. This is also how the fabricatr package simulates clustered data.

So, even though clustered data are formally defined as draws from a multivariate distribution, is it actually necessary to simulate draws from a multivariate, or can you just simulate from a univariate, like so:

  n = 1000
  c = 50
  df = data.frame(
    agent = 1:n,
    cluster = rep(1:c, each = n/c)
  df$x = df$u_i = rnorm(n = n, mean = 0, sd = 1)
  df$u_c = rep(rnorm(c, mean = 0, sd = 10), each = n/c)
  df$y = 1 + 5*(df$x + df$u_c) + (df$u_c + df$u_i)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.