Learn R Programming

IntervalQuestionStat (version 0.2.0)

cov: Calculate the sample covariance between two random intervals

Description

This function calculates the sample covariance between two realizations of \(n\) nonempty compact real intervals drawn from two random intervals saved as two different IntervalList objects.

Usage

# S4 method for IntervalList,IntervalList
cov(x, y, theta = 1)

Value

This function returns the calculated sample covariance of two samples of \(n\) interval-valued data, which is defined as a real number. Therefore, the output of this function is a single numeric value.

Arguments

x

A list of intervals, that is, an IntervalList object.

y

A list of intervals, that is, an IntervalList object with the same length as x.

theta

A single positive real number saved as a numeric object. By default, theta = 1.

Author

José García-García garciagarjose@uniovi.es

Details

Let \(\mathcal{X}\) and \(\mathcal{Y}\) be two interval-valued random sets and let \(\left((x_{1},y_{1}),(x_{2},y_{2}), \ldots, (x_{n},y_{n})\right)\) be a sample of \(n\) independent observations drawn from \(\left(\mathcal{X},\mathcal{Y}\right)\). Then, the sample covariance between \(\mathcal{X}\) and \(\mathcal{Y}\) is defined as the following real number given by $$s_{\mathcal{X}~\mathcal{Y}} = s_{\mathrm{mid}~\mathcal{X}~\mathrm{mid}~\mathcal{Y}}+\theta\cdot s_{\mathrm{spr}~\mathcal{X}~\mathrm{spr}~\mathcal{Y}},$$ where \(\theta>0\) and $$s_{\mathrm{mid}~\mathcal{X}~\mathrm{mid}~\mathcal{Y}} = \frac{1}{n}\sum_{i=1}^{n}(\mathrm{mid}~x_{i} - \mathrm{mid}~\overline{x})(\mathrm{mid}~y_{i}-\mathrm{mid}~\overline{y}),$$ $$s_{\mathrm{spr}~\mathcal{X}~\mathrm{spr}~\mathcal{Y}} = \frac{1}{n}\sum_{i=1}^{n}(\mathrm{spr}~x_{i} - \mathrm{spr}~\overline{x})(\mathrm{spr}~y_{i}-\mathrm{spr}~\overline{y}),$$ with \(\overline{x}\) and \(\overline{y}\) being the sample Aumann means of the given one-dimensional random samples.

See Also

Other sample central tendency and dispersion measures such as sample Aumann mean and sample Fréchet variance can be calculated through mean() and var() functions, respectively.

Examples

Run this code
## Some cov() examples changing theta
list1 <- IntervalList(c(0, 3, 2, 5, 6), c(4, 5, 4, 8, 7))
list2 <- IntervalList(c(3, 0, 3, 1, 4), c(7, 4, 6, 2, 6))
cov(list1, list2)
cov(list1, list2, 1/3)

## Note that cov(X, X) = var(X)
cov(list1, list1)
var(list1)
cov(list1, list1, 1/3)
var(list1, 1/3)

Run the code above in your browser using DataLab