# Calculate the Pearson correlation coefficient matrix for a rasterstack

Source:`R/stats.R`

`pearson_correlation_matrix.Rd`

Calculate the Pearson correlation coefficient matrix for a rasterstack

## Arguments

- x
RasterStack. The stack of rasters you want to calculate the Pearson correlation coefficient matrix for. This can be obtained by calling

`load_layers`

.- cachesize
integer. For how many rasters should the values be kept in local memory. By default this is set to 20, a parameter which works reasonably well on a windows computer with 8GB RAM.

- same_mask
logical. Whether we can assume that the mask is the same for all layers (same NA values), default is

`FALSE`

.

## Examples

```
if (FALSE) {
# calculate correlation between SST and salinity in the Baltic Sea
# warning using tempdir() implies that data will be downloaded again in the
# next R session
x <- load_layers(c("BO_sstmax", "BO_salinity"), datadir = tempdir())
e <- extent(13, 31, 52, 66)
baltics <- crop(x, e)
print(pearson_correlation_matrix(baltics))
}
```