Learn R Programming

TestIndVars (version 0.1.0)

covMatC: Generate a covariance matrix with Circular (C) structure.

Description

This function generates generates an Circular (C) covariance structure matrix of size \(p \times p\) based on the specified sequence of \(\{b_1, b_2, \ldots, b_{\lfloor p/2 \rfloor}\}\) where \(\lfloor \cdot \rfloor\) represents the largest integer that is not greater than the argument and \(b_j = b_{p -j}\) that this sequence in this function is created by a controlling parameter \(\rho\) as well as variance (\(\sigma^2\)).

Usage

covMatC(p, sigma2 = 1, rho = NULL)

Value

A \(p \times p\) numeric matrix representing the Circular (C) covariance structure.

Arguments

p

An integer specifying the number of dimensions of the covariance matrix.

sigma2

A numeric value specifying the variance parameter (default = 1).

rho

Parameter controlling the circular pattern. If not provided, a random value between 0 and 1 will be generated.

The Circular structure is defined as follows:

$$\Sigma = \Sigma_{C} = \begin{bmatrix} \sigma^2 & b_1 & b_2 & \cdots & b_{p-1} \\ b_{p-1} & \sigma^2 & b_1 & \cdots & b_{p-2} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ b_1 & b_2 & b_3 \cdots & \sigma^2 \end{bmatrix}$$ where \(\Sigma \) is the covariance matrix, \(\sigma^2\) is the variance parameter, and \(b_j\) is the sequence that \(b_j = b_{p-j}\) for \(j = 1, 2, \ldots, \lfloor p/2 \rfloor\) where \(\lfloor \cdot \rfloor\) represents the largest integer that is not greater than the argument.

Examples

Run this code
# generate a covariance matrix for \eqn{p = 5}, \eqn{\sigma^2 = 1}, and \eqn{\rho = 0.9}.
covMatC(p = 5, rho = 0.9)

# generate a covariance matrix for \eqn{p = 5},  \eqn{\sigma^2 = 5}, and \eqn{\rho = 0.9}.
covMatC(p = 5, sigma2 = 5, rho = 0.9)

# generate  covariance matrix for \eqn{p = 5},  and no value is considered for \eqn{\rho}
covMatC(p = 5)

Run the code above in your browser using DataLab