Construct a logistic-normal covariance matrix
get_logistN_Sigma.RdBuilds the covariance matrix \(\Sigma\) used in logistic-normal
composition likelihoods for a given correlation structure. Three structures
are supported, matching the comp_like codes used throughout SPoRC:
iid (2), AR(1) across bins (3), and AR(1) across bins with
constant correlation across sexes via a Kronecker product (4).
Arguments
- comp_like
Integer. Covariance structure:
2= iid (diagonal \(\theta^2 I\)),3= AR(1) across bins (\(\theta^2 C_{\text{AR1}}\)),4= Kronecker product of constant sex correlation and AR(1) bin correlation (\(\theta^2 (C_{\text{sex}} \otimes C_{\text{AR1}})\)).- n_bins
Integer. Number of composition categories (ages or lengths). The resulting matrix has dimension
n_binsforcomp_like2and3, orn_bins × n_sexesforcomp_like = 4.- n_sexes
Integer. Number of sexes. Required for
comp_like = 4; ignored otherwise.- theta
Numeric. Marginal standard deviation \(\theta > 0\) controlling the overall scale of \(\Sigma\).
- corr_b
Numeric. AR(1) correlation across bins in \((-1, 1)\). Required for
comp_like3and4; ignored forcomp_like = 2.- corr_s
Numeric. Constant (exchangeable) correlation across sexes in \((-1, 1)\). Required for
comp_like = 4; ignored otherwise.
Value
Numeric covariance matrix \(\Sigma\) of dimension
n_bins × n_bins (comp_like 2, 3) or
(n_bins × n_sexes) × (n_bins × n_sexes) (comp_like = 4).
Examples
if (FALSE) { # \dontrun{
# iid
get_logistN_Sigma(comp_like = 2, n_bins = 5, n_sexes = NULL, theta = 0.5)
# AR(1) across bins
get_logistN_Sigma(comp_like = 3, n_bins = 5, n_sexes = NULL,
theta = 0.5, corr_b = 0.3)
# AR(1) across bins x constant across sexes
get_logistN_Sigma(comp_like = 4, n_bins = 5, n_sexes = 2,
theta = 0.5, corr_b = 0.3, corr_s = 0.2)
} # }