Computes the pseudo-likelihood function of a Markov Random Field on a 2-dimensional lattice.

pl_mrf2d(Z, mrfi, theta, log_scale = TRUE)

Arguments

Z

A matrix with integers in {0,...,C}.

mrfi

A mrfi object representing the interaction structure.

theta

A 3-dimensional array describing potentials. Slices represent interacting positions, rows represent pixel values and columns represent neighbor values. As an example: theta[1,3,2] has the potential for the pair of values 0,2 observed in the second relative position of mrfi.

log_scale

A logical value indicating whether the returned value should be in logarithmic scale.

Value

A numeric with the pseudo-likelihood value.

Details

The pseudo-likelihood function is defined as the product of conditional probabilities of each pixel given its neighbors:

$$\prod_i P(Z_i | Z_{{N}_i}, \theta).$$

See also

A paper with detailed description of the package can be found at doi: 10.18637/jss.v101.i08 .

Author

Victor Freguglia

Examples

pl_mrf2d(Z_potts, mrfi(1), theta_potts)
#> [1] -10708.08