knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )

```
library(mrf2d)
```

The model used in `mrf2d`

is very flexible, but many simpler and popular models of the Markov Random Field literature can be written as particular cases. It considers the probability function:
\begin{equation}
\mathbb{P}(\mathbf{Z} = \mathbf{z}) =
\frac{1}{\zeta_{\theta}} \exp \left( \sum_{r \in \mathcal{R}} \sum_{i,j \in \mathcal{L}}
\theta_{z_i, z_j, r} \delta(j = i+r) ) \right),
\end{equation}
where $\zeta_\theta$ is the normalizing constant and $\mathcal{R}$ is a set of relative positions (`mrfi`

objects). The probability function of many other models like the Ising model and the Potts model can be written by adding constraints to the array $\theta_{a,b,r}$.

Important tasks like extracting sufficient statistics and estimating the parameters $\theta_{a,b,r}$ must be able to reflect the parameter restrictions required by those less general models. Functions which result is affected by those restrictions take a `family`

argument which determines what kind of restriction is considered. 5 families are available in `mrf2d`

and this short article describes each them.

`'onepar'`

A single parameter for all different-valued pairs in all interacting positions.

fit_pl(field1, mrfi(1), family = "onepar")

`'oneeach'`

One parameter for all different-valued pairs **for each** interacting position.

fit_pl(field1, mrfi(1), family = "oneeach")

`'absdif'`

One parameter for each **absolute** difference of interacting pairs $d = |b-a|$ in each relative position.

fit_pl(field1, mrfi(1), family = "absdif")

`'dif'`

One parameter for each difference of interacting pairs $d = b-a$ in each relative position.

fit_pl(field1, mrfi(1), family = "dif")

`'free'`

Only the identifiability restriction $\theta_{0,0,r} = 0$ for all $r \in \mathcal{R}$.

fit_pl(field1, mrfi(1), family = "free")

**Any scripts or data that you put into this service are public.**

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.