Compute the correlation matrix for a low-rank structure.
corLevLowRank(par, nlevels, rank, levels,
              lowerSQRT = FALSE, compGrad = TRUE,
              cov = 0, impl = c("C", "R"))A correlation matrix (or its root) with the optional gradient
attribute.
A numeric vector with length npCor + npVar where
    npCor = (rank - 1) * (nlevels - rank / 2) is the number of
    correlation parameters, and npVar is the number of variance
    parameters, which depends on the value of cov. The value of
    npVar is 0, 1 or nlevels corresponding
    to the values of cov: 0, 1 and 2.  The
    correlation parameters are assumed to be located at the head of
    par i.e. at indices 1 to npCor. The variance
    parameter(s) are assumed to be at the tail, i.e. at indices
    npCor +1  to npCor + npVar.
Number of levels \(m\).
The rank, which must be >1 and < nlevels.
Character representing the levels.
Logical. When TRUE a lower-triangular root
    \(\mathbf{L}\) of the correlation or covariance matrix
    \(\mathbf{C}\) is returned instead of the correlation
    matrix. Note that this matrix can have negative diagonal elements
    hence is not a (pivoted) Cholesky root.
Logical. Should the gradient be computed? This is only possible for the C implementation.
Integer 0, 1 or 2. If cov is 0,
    the matrix is a correlation matrix (or its root). If
    cov is 1 or 2, the matrix is a
    covariance (or its root) with constant variance vector for
    code = 1 and with arbitrary variance for code = 2. The
    variance parameters par are located at the tail of the
    par vector, so at locations npCor + 1 to npCor +
    nlevels when code = 2 where npCor is the number of
    correlation parameters.
A character telling which of the C and R implementations should be chosen. The R implementation is only for checks and should not be used.
The correlation matrix with size \(m\) is the general symmetric correlation matrix with rank \(\leq r\) where \(r\) is given, as described by Rapisarda et al. It depends on \((r - 1) \times (m - r / 2) / 2\) parameters \(\theta_{ij}\) where the indices \(i\) and \(j\) are such that \(1 \leq j < i\) for \(i \leq r\) or such that \(1 \leq j < r\) for \(r < i \leq n\). The parameters \(\theta_{ij}\) are angles and are to be taken to be in \([0, 2\pi)\) if \(j = 1\) and in \([0, \pi)\) otherwise.
Francesco Rapisarda, Damanio Brigo, Fabio Mercurio (2007). "Parameterizing Correlations a Geometric Interpretation". IMA Journal of Management Mathematics, 18(1): 55-73.
Igor Grubišić, Raoul Pietersz (2007). "Efficient Rank Reduction of Correlation Matrices". Linear Algebra and its Applications, 422: 629-653.
The q1LowRank creator of a corresponding kernel object
  with class "covQual", and the similar corLevSymm
  function for the full-rank case.