Description Usage Arguments Details Value Author(s) References Examples
Calculate conditional probabilities of a matrix from the joint and marginal probabilities.
1 | cpf(pxy, margin)
|
pxy |
A matrix, array, or data frame of numeric values representing the joint distribution across all interactions of X and Y (must sum to 1) in the form:
| |||||||||||||||||||||||||
margin |
a character argument that can be either "p(row|col)" or "p(col|row)" indicating if the desired conditional probability is p(row|col) or p(col|row). In these example data p(row|col) corresponds to p(to|from). |
cpf
calculates the conditional probabilities
p(Y|X) across all discrete interactions of the two variables.
Let PXY be a matrix of joint probabilities with rows j
and columns i and let PX_i represent a vector
of marginal probabilities. The probability of event Y under
the condition that X has already occurred is found by:
PXX_i,j / PX_i = PX_Yi,j
wherever PX_i is greater than zero.
Returns a matrix of conditional probabilities with the same number of rows and columns as input matrix PXY and has the form:
p(y|x) | X | |||
0.19 | 0.19 | 0.18 | ... | |
Y | 0.44 | 0.44 | 0.41 | ... |
0.38 | 0.38 | 0.41 | ... | |
... | ... | ... | ... |
Bjorn J. Brooks, Lars Y. Pomara, Danny C. Lee
PAPER TITLE.
1 2 3 4 5 6 7 8 9 10 | data(transitions) # Load example data
b <- brkpts(transitions$phenofr, # 4 probabilistically
4) # equivalent breakpoints
m <- xt(transitions, # Make transition matrix
fr.col=2, to.col=3,
cnt.col=4, brk=b)
pxy <- jpmf(m) # Joint distribution
r_c <- cpf(pxy, # Conditional probabilites
margin='p(row|col)') # (row | col)
colSums(r_c) # Check that each column sums to 1
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.