# Y-structure MAG# Encode as adjacency matrixp <-4# total number of variablesV <- c("X1","X2","X3","X4")# variable labels# amat[i,j] = 0 iff no edge btw i,j# amat[i,j] = 1 iff i *-o j# amat[i,j] = 2 iff i *-> j# amat[i,j] = 3 iff i *-- jamat <- rbind(c(0,0,2,0), c(0,0,2,0), c(3,3,0,2), c(0,0,3,0))rownames(amat)<-V
colnames(amat)<-V
## d-separatedcat('X1 d-separated from X2? ', dsepAM(1,2,S=NULL,amat),'\n')## not d-separated given node 3cat('X1 d-separated from X2 given X4? ', dsepAM(1,2,S=4,amat),'\n')## not d-separated by node 3 and 4cat('X1 d-separated from X2 given X3 and X4? ', dsepAM(1,2,S=c(3,4),amat),'\n')