diff_cov {oeli}R Documentation

Difference and un-difference covariance matrix

Description

These functions difference and un-difference a covariance matrix with respect to row ref.

Usage

diff_cov(cov, ref = 1)

undiff_cov(cov_diff, ref = 1)

delta(ref = 1, dim)

Arguments

cov, cov_diff

A (differenced) covariance matrix of dimension dim (or dim - 1, respectively).

ref

An integer between 1 and dim, the reference row for differencing that maps cov to cov_diff, see details. By default, ref = 1.

dim

An integer, the dimension.

Details

For differencing: Let Σ\Sigma be a covariance matrix of dimension nn. Then

Σ~=ΔkΣΔk\tilde{\Sigma} = \Delta_k \Sigma \Delta_k'

is the differenced covariance matrix with respect to row k=1,,nk = 1,\dots,n, where Δk\Delta_k is a difference operator that depends on the reference row kk. More precise, Δk\Delta_k the identity matrix of dimension nn without row kk and with 1-1s in column kk. It can be computed with delta(ref = k, dim = n).

For un-differencing: The "un-differenced" covariance matrix Σ\Sigma cannot be uniquely computed from Σ~\tilde{\Sigma}. For a non-unique solution, we add a column and a row of zeros at column and row number kk to Σ~\tilde{\Sigma}, respectively, and add 11 to each matrix entry to make the result a proper covariance matrix.

Value

A (differenced or un-differenced) covariance matrix.

Examples

n <- 3
Sigma <- sample_covariance_matrix(dim = n)
k <- 2

# build difference operator
delta(ref = k, dim = n)

# difference Sigma
(Sigma_diff <- diff_cov(Sigma, ref = k))

# un-difference Sigma
undiff_cov(Sigma_diff, ref = k)


[Package oeli version 0.5.2 Index]