Skip to contents

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

Usage

measure_variances(mat, estimate = FALSE)

Arguments

mat

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

estimate

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      Value Proportion
#> 1            Main effect 0.21469751 0.60715081
#> 2            Interaction 0.13891729 0.39284919
#> 3 Heterogeniety of scale 0.02239313 0.06332633
#> 4    Lack of correlation 0.11652416 0.32952286
#> 5          Non-crossover 0.24240025 0.68549236
#> 6              Crossover 0.11121456 0.31450764
#> 7                  Total 0.35361480 1.00000000