Set or retrieve correlations or covariances between `errors`

objects.
See the details section below.

## Usage

```
correl(x, y)
correl(x, y) <- value
set_correl(x, y, value)
covar(x, y)
covar(x, y) <- value
set_covar(x, y, value)
```

## Arguments

- x
an object of class

`errors`

.- y
an object of class

`errors`

.- value
a numeric vector of length 1 or the same length as

`x`

.

## Value

`correl`

and `covar`

return a vector of correlations and
covariances respectively (or `NULL`

).
`set_correl`

and `set_covar`

, which are pipe-friendly versions of
the setters, return the `x`

object.

## Details

The uncertainties associated to `errors`

objects are supposed
to be independent by default. If there is some known correlation, it can be
defined using these methods, and it will be used for the propagation of the
uncertainty by the mathematical and arithmetic operations.

The `correl`

method sets or retrieves correlations, i.e., a value (or
vector of values) between `-1`

and `1`

(see base `cor`

on how to compute correlations). A covariance is just a correlation value
multiplied by the standard deviations (i.e., the standard uncertainty) of
both variables. It can be defined using the `covar`

method (see base
`cov`

on how to compute covariances). These methods are
equivalent; in fact, `correl`

calls `covar`

internally.

Every `errors`

object has a unique ID, and pairwise correlations are
stored in an internal hash table. All the functions or methods that modify
somehow the dimensions of `errors`

objects (i.e., subsets, binds,
concatenations, summaries...) generate new objects with new IDs, and
correlations are not, and cannot be, propagated. Only mathematical and
arithmetic operations propagate correlations, where appropriate, following
the Taylor series method.

## Examples

```
x <- set_errors(1:5, 0.1)
y <- set_errors(1:5, 0.1)
# Self-correlation is of course 1, and cannot be changed
correl(x, x)
#> [1] 1 1 1 1 1
if (FALSE) {
correl(x, x) <- 0.5}
# Cross-correlation can be set, but must be a value between -1 and 1
correl(x, y)
#> NULL
if (FALSE) {
correl(x, y) <- 1.5}
correl(x, y) <- runif(length(x))
correl(x, y)
#> [1] 0.4302361 0.7587186 0.7049226 0.4014451 0.1548518
covar(x, y)
#> [1] 0.004302361 0.007587186 0.007049226 0.004014451 0.001548518
```