as_cpt {sparta} | R Documentation |
As cpt
Description
Turn a sparta into a conditional probability table
Usage
as_cpt(x, y)
## S3 method for class 'sparta'
as_cpt(x, y)
Arguments
x |
sparta object |
y |
the conditioning variables |
Examples
x <- array(
c(1,0,0,2,3,4,0,0),
dim = c(2,2,2),
dimnames = list(
a = c("a1", "a2"),
b = c("b1", "b2"),
c = c("c1", "c2")
)
)
sx <- as_sparta(x)
# A joint probability table p(a, b, c)
as_cpt(sx, character(0))
# the same as normalize
normalize(sx)
# A conditional probability table p(a, c | b)
pacb <- as_cpt(sx, "b")
# The probability distribution when b = b1
slice(pacb, c(b = "b1"))
[Package sparta version 0.8.4 Index]