We can decompose Bayes’ Theorem into three principal terms: \[\begin{eqnarray*} p(\theta|x) & \qquad& \text{posterior}\\ p(x|\theta) & \qquad& \text{likelihood}\\ p(\theta) & \qquad& \text{prior} \end{eqnarray*}\]
\[\mbox{Posterior}= \mbox{Likelihood}\frac{\mbox{Proposition prior probability}}{\mbox{Evidence prior probability}}\]
library(Rgraphviz)
DAG.matrix = matrix(c(0, 1, 0, 1, 0, 0, 0), ncol = 6, nrow = 6)
rownames(DAG.matrix) = c("A", "B", "C", "X", "Y", "Z")
colnames(DAG.matrix) = c("A", "B", "C", "X", "Y", "Z")
DAG.matrix A B C X Y Z
A 0 0 0 0 1 0
B 1 0 0 0 0 1
C 0 1 0 0 0 0
X 1 0 1 0 0 0
Y 0 1 0 1 0 0
Z 0 0 1 0 1 0
am.graph = new("graphAM", adjMat = DAG.matrix, edgemode = "directed") \[P(A,B,C,X,Y,Z) = P(A|B)*P(B)\]
\[P(x_{1}, x_{2},...x_{N} )\prod_{i=1}^N P(x_{i}|parent(x_{i})) \]
If a causal relationship between variables X and Y is said to be d-separated for a set of given variables A, then X and Y are conditionally independent given the set A. The meaning of d-separated is analogue to directional-unconnected.
library(Rgraphviz)
nodes <- c("a", "b", "c", "d", "e", "f", "g", "h", "m", "n", "o", "p", "q", "r",
"s", "t", "z")
# edges
edgeList <- list(a = list(edges = c("d")), b = list(edges = c("n")), c = list(edges = c("b")),
d = list(edges = c("g")), e = list(edges = c("n")), f = list(edges = c("c")),
g = list(edges = c("s")), h = list(edges = c("e")), m = list(edges = c("z")),
n = list(edges = c("b", "r")), o = list(edges = c("h")), p = list(edges = c("m")),
q = list(edges = c("n", "r")), r = list(edges = c("f")), s = list(edges = c("z")),
t = list(edges = c("o")), z = list(edges = c("t")))
graph01 <- new("graphNEL", nodes = nodes, edgeL = edgeList, edgemode = "directed")