Learn R Programming

glmmTMB (version 1.0.2.1)

get_cor: translate vector of correlation parameters to correlation values

Description

translate vector of correlation parameters to correlation values

Usage

get_cor(theta)

Arguments

theta

vector of internal correlation parameters

Value

a vector of correlation values

Details

This function follows the definition at http://kaskr.github.io/adcomp/classUNSTRUCTURED__CORR__t.html: if \(L\) is the lower-triangular matrix with 1 on the diagonal and the correlation parameters in the lower triangle, then the correlation matrix is defined as \(\Sigma = D^{-1/2} L L^\top D^{-1/2}\), where \(D = \textrm{diag}(L L^\top)\). For a single correlation parameter \(\theta_0\), this works out to \(\rho = \theta_0/\sqrt{1+\theta_0^2}\). The function returns the elements of the lower triangle of the correlation matrix, in column-major order.

Examples

Run this code
# NOT RUN {
th0 <- 0.5
stopifnot(all.equal(get_cor(th0),th0/sqrt(1+th0^2)))
get_cor(c(0.5,0.2,0.5))
# }

Run the code above in your browser using DataLab