## Example from the asia dataset from Lauritzen and Spiegelhalter (1988)
## provided by Scutari (2010)
# The number of MCMC run is deliberately chosen too small (computing time)
# no thinning (usually not recommended)
# no burn-in (usually not recommended,
# even if not supported by any theoretical arguments)
# Let us run: 0.03 REV, 0.03 MBR, 0.94 MC3 MCMC jumps
# with a random DAG as starting point
mcmc.out.asia.small <- mcmcabn(score.cache = abnCache.2par.asia,
score = "mlik",
data.dists = dist.asia,
max.parents = 2,
mcmc.scheme = c(50,0,0),
seed = 321,
verbose = FALSE,
start.dag = "random",
prob.rev = 0.03,
prob.mbr = 0.03,
prior.choice = 2)
summary(mcmc.out.asia.small)
# Soly with MC3 moves:
mcmc.out.asia.small <- mcmcabn(score.cache = abnCache.2par.asia,
score = "mlik",
data.dists = dist.asia,
max.parents = 2,
mcmc.scheme = c(50,0,0),
seed = 42,
verbose = FALSE,
start.dag = "random",
prob.rev = 0,
prob.mbr = 0,
prior.choice = 2)
summary(mcmc.out.asia.small)
# Defining a starting DAG
startDag <- matrix(data = c(0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0),nrow = 8,ncol = 8, byrow = TRUE)
colnames(startDag) <- rownames(startDag) <- names(dist.asia)
# Additionally, let us use the non informative prior:
mcmc.out.asia.small <- mcmcabn(score.cache = abnCache.2par.asia,
score = "mlik",
data.dists = dist.asia,
max.parents = 2,
mcmc.scheme = c(50,0,0),
seed = 42,
verbose = FALSE,
start.dag = startDag,
prob.rev = 0,
prob.mbr = 0,
prior.choice = 1)
summary(mcmc.out.asia.small)
# Let us define our very own prior
# we know that there should be a link between Smoking and LungCancer nodes
# uninformative prior matrix
priorDag <- matrix(data = 0.5,nrow = 8,ncol = 8)
# name it
colnames(priorDag) <- rownames(priorDag) <- names(dist.asia)
# parent = smoking; child = LungCancer
priorDag["LungCancer","Smoking"] <- 1
mcmc.out.asia.small <- mcmcabn(score.cache = abnCache.2par.asia,
score = "mlik",
data.dists = dist.asia,
max.parents = 2,
mcmc.scheme = c(50,0,0),
seed = 42,
verbose = FALSE,
start.dag = startDag,
prob.rev = 0,
prob.mbr = 0,
prior.choice = 3,
prior.dag = priorDag)
summary(mcmc.out.asia.small)
# Let us improve the convergence rate. The 20 first MCMC moves are performed with an
# heating parameter different than one, afterward, heating is set up to one.
mcmc.out.asia.small <- mcmcabn(score.cache = abnCache.2par.asia,
score = "mlik",
data.dists = dist.asia,
max.parents = 2,
mcmc.scheme = c(100,0,0),
seed = 41242,
verbose = FALSE,
start.dag = "random",
prob.rev = 0.03,
prob.mbr = 0.03,
prior.choice = 2, heating = 20)
summary(mcmc.out.asia.small)
Run the code above in your browser using DataLab