set.seed(0)
N<-500
n<-5
X<-array(rnorm(N*n),c(N,n))
Y<-X[,1]-3*X[,3]+4*X[,2]+rnorm(N,sd=0.5)
Z1<-Y+rnorm(N,sd=0.5)
## effect 1
Z2<-2*Y+rnorm(N,sd=0.5)
## effect 2
most.probable.causes<-mimr(cbind(X,Z1,Z2),Y,nmax=3,init=TRUE,spouse=FALSE,lambda=1)
## causes are in the first three columns of the feature dataset
most.probable.effects<-mimr(cbind(X,Z1,Z2),Y,nmax=3,init=TRUE,spouse=FALSE,lambda=1,caus=-1)
## effects are in the last two columns of the feature dataset
Run the code above in your browser using DataLab