This function checks if a kinship matrix is invertible by computing the smallest eigenvalue using the rARPACK package. If all eigenvalues are positive, the matrix is positive definite and thus invertible.

check_invertible(kinship_matrix, tolerance = 1e-10)

Arguments

kinship_matrix

A symmetric matrix of kinship coefficients

tolerance

Numerical tolerance for considering an eigenvalue as zero (default: 1e-10)

Value

A list containing:

  • is_invertible: Logical indicating if matrix is invertible

  • condition_number: Ratio of largest to smallest eigenvalue

  • min_eigenvalue: The smallest eigenvalue

  • max_eigenvalue: The largest eigenvalue

Examples

ped <- simulate_pedigree(n_founders = 5, n_generations = 2)
k <- calculate_kinship(ped)
check_invertible(k)
#> $is_invertible
#> [1] TRUE
#> 
#> $condition_number
#> [1] 25.96251
#> 
#> $min_eigenvalue
#> [1] 0.07275929
#> 
#> $max_eigenvalue
#> [1] 1.889014
#>