---
title: "Parameter restriction families in mrf2d"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Parameter restriction families in mrf2d}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
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.

### Example

```{r}
fit_pl(field1, mrfi(1), family = "onepar")
```


# `'oneeach'`

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

### Example

```{r}
fit_pl(field1, mrfi(1), family = "oneeach")
```


# `'absdif'`

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

### Example

```{r}
fit_pl(field1, mrfi(1), family = "absdif")
```


# `'dif'`

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

### Example

```{r}
fit_pl(field1, mrfi(1), family = "dif")
```


# `'free'`

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

### Example

```{r}
fit_pl(field1, mrfi(1), family = "free")
```

