set.seed(0) | |
nobs = 100 | |
nind = 100 | |
nlevels <- 4 | |
levels.cat <- rnorm(n = nlevels, mean = 0, sd = 2) | |
indbt <- rnorm(n = nind, mean = 0, sd = 2) | |
id <- rep(1:nind, each = nobs) | |
categorique <- sample(x = 1:4, size = nobs*nind, replace = TRUE) | |
table.cat <- data.frame(categorique = 1:4, val = levels.cat) | |
x1 <- runif(min = 0, max = 1, n = nobs*nind) | |
x2 <- runif(min = 0, max = 1, n = nobs*nind) | |
y <- 2 + x1*3 + x2*(-2) + 0.5*x1*x2 + rep(indbt, each = nobs) + table.cat$val[match(categorique, table.cat$categorique)] + rnorm(sd = 2, n = nobs*nind) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment