check_invertible.RdThis 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)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
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
#>