This function generates a \(p \times p\) intraclass covariance matrix with correlation rho. The variance sigma2 is constant for each feature and defaulted to 1.

cov_intraclass(p, rho, sigma2 = 1)

Arguments

p

the size of the covariance matrix

rho

the value of the off-diagonal elements

sigma2

the variance of each feature

Value

intraclass covariance matrix

Details

The intraclass covariance matrix is defined as: $$\sigma^2 * (\rho * J_p + (1 - \rho) * I_p),$$ where \(J_p\) is the \(p \times p\) matrix of ones and \(I_p\) is the \(p \times p\) identity matrix.

By default, with sigma2 = 1, the diagonal elements of the intraclass covariance matrix are all 1, while the off-diagonal elements of the matrix are all rho.

The value of rho must be between \(1 / (1 - p)\) and 1, exclusively, to ensure that the covariance matrix is positive definite.