# NOT RUN {
library(MASS)
# draw from multivariate normal distribution
draw_multivariate(c(Y_1, Y_2) ~ mvrnorm(
n = 5,
mu = c(0, 0),
Sigma = matrix(c(10, 3, 3, 2), 2, 2)
))
# equivalently, you can provide a prefix for the variable names
# (easier if you have many variables)
draw_multivariate(Y ~ mvrnorm(
n = 5,
mu = c(0, 0),
Sigma = matrix(c(10, 3, 3, 2), 2, 2)
))
# within fabricate
fabricate(
N = 100,
draw_multivariate(c(Y_1, Y_2) ~ mvrnorm(
n = N,
mu = c(0, 0),
Sigma = matrix(c(10, 3, 3, 2), 2, 2)
))
)
# You can also write the following, which works but gives less control over the names
fabricate(N = 100,
Y = mvrnorm(
n = N,
mu = c(0, 0),
Sigma = matrix(c(10, 3, 3, 2), 2, 2)
))
# }
Run the code above in your browser using DataLab