# NOT RUN {
##############################################
## example 1: use built-in simulated data set
##############################################
mydat<-ex1.dag.data; ## this data comes with abn see ?ex1.dag.data
## setup distribution list for each node
mydists<-list(b1="binomial",
p1="poisson",
g1="gaussian",
b2="binomial",
p2="poisson",
b3="binomial",
g2="gaussian",
b4="binomial",
b5="binomial",
g3="gaussian"
);
## not run because may take some minutes for buildscorecache()
## parent limits
max.par<-list("b1"=4,"p1"=4,"g1"=4,"b2"=4,"p2"=4,"b3"=4,"g2"=4,"b4"=4,"b5"=4,"g3"=4);
## now build cache
mycache<-buildscorecache(data.df=mydat,data.dists=mydists,,max.parents=max.par);
# now peform 1000 greedy searches
heur.res<-search.hillclimber(score.cache=mycache,
num.searches=1000,seed=0,verbose=FALSE,timing.on=FALSE);
# repeat but this time have the majority consensus network plotted as the searches progress
heur.res2<-search.hillclimber(score.cache=mycache,
num.searches=1000,seed=0,verbose=FALSE,trace=TRUE,timing.on=FALSE);
###################################################################################################
## example 2 - glmm example - but no difference here as the format of the score cache is identical
###################################################################################################
mydat<-ex3.dag.data[,c(1:5,14)];## this data comes with abn see ?ex1.dag.data
mydists<-list(b1="binomial",
b2="binomial",
b3="binomial",
b4="binomial",
b5="binomial"
);
max.par<-3;
mycache.mixed<-buildscorecache(data.df=mydat,data.dists=mydists,group.var="group",
cor.vars=c("b1","b2","b3","b4","b5"),
max.parents=max.par, which.nodes=c(1:5));
# now peform 1000 greedy searches
heur.res<-search.hillclimber(score.cache=mycache.mixed,num.searches=1000,
seed=0,verbose=FALSE,timing.on=FALSE);
plotabn(dag.m = heur.res$consensus,data.dists = mydists)
# repeat but this time have the majority consensus network plotted as the searches progress
heur.res2<-search.hillclimber(score.cache=mycache.mixed,num.searches=1000,seed=0,
verbose=FALSE,trace=TRUE,timing.on=FALSE);
# }
Run the code above in your browser using DataLab