`matrigraph()`

produces a heatmap highlighting the deviations from independence.`pvi()`

computes for each cell of a numeric matrix the percentage to the column theoretical independence value.

## Usage

```
matrigraph(object, ...)
pvi(object, ...)
# S4 method for matrix
pvi(object)
# S4 method for data.frame
pvi(object)
# S4 method for matrix
matrigraph(object, reverse = FALSE)
# S4 method for data.frame
matrigraph(object, reverse = FALSE)
```

## Arguments

- object
A \(m \times p\)

`numeric`

`matrix`

or`data.frame`

of count data (absolute frequencies giving the number of individuals for each class).- ...
Currently not used.

- reverse
A

`logical`

scalar: should negative deviations be centered (see details)?

## Value

`matrigraph()`

returns a ggplot2::ggplot object.

## Details

PVI (in french "pourcentages de valeur d'indépendance") is calculated for each cell as the percentage to the column theoretical independence value: PVI greater than \(1\) represent positive deviations from the independence, whereas PVI smaller than \(1\) represent negative deviations (Desachy 2004).

The PVI matrix allows to explore deviations from independence (an intuitive approach to \(\chi^2\)), in such a way that a high-contrast matrix has quite significant deviations, with a low risk of being due to randomness (Desachy 2004).

`matrigraph()`

displays the deviations from independence:

If the PVI is equal to \(1\) (statistical independence), the cell of the matrix is filled in grey.

If the PVI is less than \(1\) (negative deviation from independence), the size of the grey square is proportional to the PVI (the white margin thus represents the fraction of negative deviation).

If the PVI is greater than \(1\) (positive deviation), a black square representing the fraction of positive deviations is superimposed. For large positive deviations (PVI greater than \(2\)), the cell in filled in black.

If `reverse`

is `TRUE`

, the fraction of negative deviations is displayed
as a white square.

## References

Desachy, B. (2004). Le sériographe EPPM: un outil informatisé de sériation
graphique pour tableaux de comptages. *Revue archéologique de Picardie*,
3(1), 39-56. doi:10.3406/pica.2004.2396
.

## See also

Other plot methods:
`plot_bertin()`

,
`plot_diceleraas()`

,
`plot_diversity`

,
`plot_ford()`

,
`plot_heatmap()`

,
`plot_rank()`

,
`plot_spot()`

,
`seriograph()`

## Examples

```
data("compiegne", package = "folio")
## Matrigraph
matrigraph(compiegne)
matrigraph(compiegne, reverse = TRUE)
## Compute EPPM
counts_pvi <- pvi(compiegne)
plot_heatmap(counts_pvi) +
khroma::scale_fill_BuRd(name = "PVI", midpoint = 1)
```