I am working in R, using MASS to create multivariate distributed vectors.

I am trying to create 1000 values for Y, which need to be computed by the formula given in the second to last row of the code. When I run this, R says that there are 50 or more warnings, where the first one says:

Error: unexpected ')' in "()"

Can anyone tell me if my code is correct for what I am attempting to do?

Y <- c()

for(i in 1:1000){
  U <- rnorm(n=40, mean=0, sd=0.04)
  X <- mvrnorm(n=40, mu=mu, Sigma=S)
  Y[i] <- 1.1 - 2.4*X[,1] + 1.4*X[,2] + U

0 Answers