# Junction tree algorithm for pairwise binary Markov networks

### Description

Calculates the expections and second moments for a pairwise binary Markov network using the junction tree algorithm.

### Usage

1 |

### Arguments

`thetaMat` |
Theta matrix of the model (assumed to be symmetric). |

`adjMat` |
Adjacency matrix of the underlying graph. If not given, inferred from |

`var` |
if given, the expectation and second moments of variable var only will be calculated. Otherwise, for all variables. |

`onlyActive` |
If |

`timeout` |
Number of seconds until the functions terminates automatically. |

### Details

Uses the junction tree algorithm to calculate the matrix of second moments of the underlying pairwise binary Markov model. This is useful for inference on this type of models as the matrix of second moments is the derivative of the partition function in this class of models. The function provides the option to calculate the second moments only for one variable with all the others (variables are numbered from 1 to p; see `var`

). Also, the juntion tree algorithm is by a factor p more efficient if only second moments corresponding to edges in the underlying graph (non-zero values in the `thetaMat`

or `adjMat`

) are being calculated. This can be done using the switch `onlyActive`

.

### Value

The return value is a list with elements:

`Expectation` |
Expectation of the variables. |

`SecondMomentMatrix` |
Second moments of the variables (only present if |

`SecondMomentVector` |
Vector of second moments of variable |

### Author(s)

Holger Hoefling

### See Also

`BMNPseudo`

, `BMNExact`

### Examples

1 2 3 4 5 6 |