Description Usage Arguments Details Value Author(s) References See Also Examples

This function samples states from the Ising model using one of three methods. See details.

1 2 | ```
IsingSampler(n, graph, thresholds, beta = 1, nIter = 100, responses = c(0L, 1L),
method = c("MH", "CFTP", "direct"), CFTPretry = 10, constrain)
``` |

`n` |
Number of states to draw |

`graph` |
Square matrix indicating the weights of the network. Must be symmetrical with 0 as diagonal. |

`thresholds` |
Vector indicating the thresholds, also known as the external field. |

`beta` |
Scalar indicating the inverse temperature. |

`nIter` |
Number of iterations in the Metropolis and exact sampling methods. |

`responses` |
Response options. Typically set to |

`method` |
The sampling method to use. Must be |

`CFTPretry` |
The amount of times a sample from CFTP may be retried. If after 100 couplings from the past the chain still results in |

`constrain` |
A (number of samples) by (number of nodes) matrix with samples that need be constrained; |

This function uses one of three sampling methods. `"MH"`

can be used to sample using a Metropolis-Hastings algorithm. The chain is initiated with random values from the response options, then for each iteration for each node a node is set to the second response option with the probability of that node being in the second response option given all other nodes and parameters. Typically, 100 of such iterations should suffice for the chain to converge.

The second method, `"CFTP"`

enhances the Metropolis-Hastings algorithm with Coupling from the Past (CFTP; Murray, 2007) to draw exact samples from the distribution. This is slower than the default Metropolis-Hastings but guarantees exact samples. However, it does depend on the graph structure and the number of nodes if these exact samples can be obtained in feasable time.

The third option, `"direct"`

, simply computes for every possibly state the probability and draws samples directly from the distribution of states by using these probabilities. This also guarantees exact samples, but quickly becomes intractible (roughly above 10 nodes).

A matrix containing samples of states.

Sacha Epskamp (mail@sachaepskamp.com)

Murray, I. (2007). Advances in Markov chain Monte Carlo methods.

`IsingSampler-package`

for examples

1 | ```
## See IsingSampler-package help page
``` |

```
Loading required package: Rcpp
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.