## Not run:
# #################################################################
# ## Example 1
# #################################################################
# mydat<-ex0.dag.data[,c("b1","b2","g1","g2","b3","g3")];## take a subset of cols
#
# ## setup distribution list for each node
# mydists<-list(b1="binomial",
# b2="binomial",
# g1="gaussian",
# g2="gaussian",
# b3="binomial",
# g3="gaussian"
# );
#
# ban<-matrix(rep(0,dim(mydat)[2]^2),ncol=dim(mydat)[2]);# ban nothing
# colnames(ban)<-rownames(ban)<-names(mydat); #names must be set
# ban["b1","b2"]<-1; # now ban arc from b2 to b1
# retain<-matrix(rep(0,dim(mydat)[2]^2),ncol=dim(mydat)[2]);# retain nothing
# colnames(retain)<-rownames(retain)<-names(mydat); #names must be set
# retain["g1","g3"]<-1; # always retain arc from g3 to g1
# # parent limits
# max.par<-list("b1"=4,"b2"=4,"g1"=4,"g2"=0,"b3"=4,"g3"=4);
#
# ## now build cache of scores (goodness of fits for each node)
#
# res.c<-buildscorecache(data.df=mydat,data.dists=mydists,
# dag.banned=ban, dag.retained=retain,max.parents=max.par
# );
#
# ## repeat but using R-INLA. The mlik's should be virtually identical.
# ## now build cache
# res.inla<-buildscorecache(data.df=mydat,data.dists=mydists,
# dag.banned=ban, dag.retained=retain,max.parents=max.par,
# max.mode.error=100);
#
# ## plot comparison - very similar
# plot(res.c$mlik,res.inla$mlik,pch="+");abline(0,1);
#
#
# #################################################################
# ## Example 2 - much bigger problem using glm - make take a while
# #################################################################
#
# mydat<-ex2.dag.data;## this data comes with abn see ?ex2.dag.data
#
# ## setup distribution list for each node
# mydists<-list(b1="binomial",
# g1="gaussian",
# p1="poisson",
# b2="binomial",
# g2="gaussian",
# p2="poisson",
# b3="binomial",
# g3="gaussian",
# p3="poisson",
# b4="binomial",
# g4="gaussian",
# p4="poisson",
# b5="binomial",
# g5="gaussian",
# p5="poisson",
# b6="binomial",
# g6="gaussian",
# p6="poisson"
# );
#
# ## parent limits
# max.par<-list("b1"=4,"g1"=4,"p1"=4,"b2"=4,"g2"=4,"p2"=4,"b3"=4,
# "g3"=4,"p3"=4,"b4"=4,"g4"=4,
# "p4"=4,"b5"=4,"g5"=4,"p5"=4,"b6"=4,"g6"=4,"p6"=4);
#
# ## no explicit ban or retain restrictions set so dont need to supply ban
# ## or retain matrices
#
# ## now build cache using internal code just for nodes 1,2 and 3
# ## e.g. "b1", "p1" and "g1"
# mycache.c<-buildscorecache(data.df=mydat,data.dists=mydists,
# max.parents=max.par, which.nodes=c(1:3));
#
# ###################################################################
# ## Example 3 - grouped data - random effects example e.g. glmm
# ###################################################################
#
# mydat<-ex3.dag.data;## this data comes with abn see ?ex3.dag.data
#
# mydists<-list(b1="binomial",
# b2="binomial",
# b3="binomial",
# b4="binomial",
# b5="binomial",
# b6="binomial",
# b7="binomial",
# b8="binomial",
# b9="binomial",
# b10="binomial",
# b11="binomial",
# b12="binomial",
# b13="binomial"
# );
# max.par<-2;
#
# ## in this example INLA is used as default since these are glmm nodes
# ## when running this at node-parent combination 71 the default accuracy check on the
# ## INLA modes is exceeded (default is a max. of 10 percent difference from
# ## modes estimated using internal code) and a message is given that internal code
# ## will be used in place of INLA's results.
#
# mycache<-buildscorecache(data.df=mydat,data.dists=mydists,group.var="group",
# cor.vars=c("b1","b2","b3","b4","b5","b6","b7",
# "b8","b9","b10",
# "b11","b12","b13"),
# max.parents=max.par, which.nodes=c(1));
#
#
# ## End(Not run)
Run the code above in your browser using DataLab