## Simulation.1
p = 100; q = 100; n = 200
rank = 3
beta = c(rep(c(rep(1,5),rep(0,95)),2))
M1 = matrix(rnorm(p*n),n,p)
U = matrix(rnorm(rank*p),p,rank)
V = matrix(rnorm(rank*q),rank,q)
B = U %*% V
E = matrix(rnorm(q*n),n,q)
M2 = M1 %*% B + E
Y = cbind(M1,M2) %*% matrix(beta,p+q,1)
Fit = MVOPR2(M1,M2,Y,RRR_Control = list(Sparsity = FALSE))
## Result for variable selection
print(data.frame(Truecoef = beta,estimate = Fit$CoefY[2:(p+q+1)]))
## Plot the pathway and cv error in outcome model
oldpar <- par(mfrow = c(1, 2))
on.exit(par(oldpar))
plot(Fit$fitY$fit)
plot(Fit$fitY)
Run the code above in your browser using DataLab