Skip to contents

Creates a table of variance components derived from a user-defined covariance matrix.

Usage

measure_variances(mat, correction = FALSE)

Arguments

mat

A symmetric n x n positive (semi)-definite variance matrix.

correction

When TRUE (default is FALSE), the variance components are treated as estimates and sample corrections are applied.

Value

A table which partitions the total variance into main effect and interaction variance, heterogeneity of variance and lack of correlation, and non-crossover and crossover interaction. When correction = TRUE, a sample correction is applied to the variance components.

Examples

# Generate a structured covariance matrix and then measure the partitioning of variance.

diag_mat <- rand_diag_mat(
  n = 10
)
cor_mat <- struc_cor_mat(
  n = 10,
)

cov_mat <- sqrt(diag_mat) %*% cor_mat %*% sqrt(diag_mat)

measure_variances(
  mat = cov_mat
)
#>                Component   Variance Proportion
#> 1            Main effect 0.29577237 0.50755525
#> 2            Interaction 0.28696690 0.49244475
#> 3 Heterogeniety of scale 0.02264701 0.03886302
#> 4    Lack of correlation 0.26431989 0.45358173
#> 5          Non-crossover 0.32363778 0.55537322
#> 6              Crossover 0.25910149 0.44462678
#> 7                  Total 0.58273927 1.00000000