# NOT RUN {
mydat<-ex0.dag.data[,c("b1","b2","b3","g1","b4","p2","p4")];## take a subset of cols
## setup distribution list for each node
mydists<-list(b1="binomial",
b2="binomial",
b3="binomial",
g1="gaussian",
b4="binomial",
p2="poisson",
p4="poisson"
);
## specify DAG model
mydag<-matrix(data=c(
0,1,0,0,1,0,0, #
0,0,0,0,0,0,0, #
0,1,0,0,1,0,0, #
1,0,0,0,0,0,1, #
0,0,0,0,0,0,0, #
0,0,0,1,0,0,0, #
0,0,0,0,1,0,0 #
), byrow=TRUE,ncol=7);
colnames(mydag)<-rownames(mydag)<-names(mydat);
## create file for processing with graphviz
tographviz(dag.m=mydag,data.df=mydat,data.dists=mydists,outfile="graph.dot",directed=TRUE);
## and then process using graphviz tools e.g. on linux
system("dot -Tpdf -o graph.pdf graph.dot")
system("evince graph.pdf");
## example using data with a group variable.
## model where b1<-b2
mydag<-matrix(data=c(
0,1, # b1
0,0 # b2
), byrow=TRUE,ncol=2);
colnames(mydag)<-rownames(mydag)<-names(ex3.dag.data[,c(1,2)]);
## specific distributions
mydists<-list(b1="binomial",
b2="binomial"
);
## create file for processing with graphviz
tographviz(dag.m=mydag,data.df=ex3.dag.data[,c(1,2,14)],data.dists=mydists,
group.var="group",outfile="graph.dot",directed=FALSE);
## and then process using graphviz tools e.g. on linux
system("dot -Tpdf -o graph.pdf graph.dot")
system("evince graph.pdf");
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab