covMatAR {TestIndVars} | R Documentation |
Generate a covariance matrix with Autoregressive (AR) structure.
Description
This function generates generates an Autoregressive (AR) covariance structure
matrix of size p \times p
based on the specified autoregressive
coefficient (\rho
) and variance (\sigma^2
).
Usage
covMatAR(p, sigma2 = 1, rho)
Arguments
p |
An integer specifying the number of dimensions of the covariance matrix. |
sigma2 |
A numeric value specifying the variance parameter (default = 1). |
rho |
A numeric value specifying the autoregressive coefficient. If not provided, a random value between 0 and 1 will be generated. The Autoregressive structure is defined as follows:
where |
Value
A p \times p
numeric matrix representing the Autoregressive (AR) covariance structure.
Examples
# generate a covariance matrix for \eqn{p = 5}, \eqn{\sigma^2 = 1}, and \eqn{\rho = 0.9}.
covMatAR(p = 5, rho = 0.9)
# generate a covariance matrix for \eqn{p = 5}, \eqn{\sigma^2 = 5}, and \eqn{\rho = 0.9}.
covMatAR(p = 5, sigma2 = 5, rho = 0.9)
# generate covariance matrix for \eqn{p = 5}, and no value is considered for \eqn{\rho}
covMatAR(p = 5)