Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SE of estimated heritability #193

Open
kbroman opened this issue Mar 4, 2021 · 1 comment
Open

SE of estimated heritability #193

kbroman opened this issue Mar 4, 2021 · 1 comment

Comments

@kbroman
Copy link
Member

kbroman commented Mar 4, 2021

There was a question at the R/qtl2 google group about getting an SE on the estimated heritability from est_herit().

Could use equation 2 from Visscher and Goddard (2015), which just depends on eigenvalues of kinship matrix, sample size, and heritability.

@kbroman
Copy link
Member Author

kbroman commented Mar 4, 2021

Here's a stab at it:

# estimated SE of estimated heritability
#
# Visscher & Goddard (2015), https://doi.org/10.1534/genetics.114.171017
#
# lambda_i = eigenvalues of K
#
# a = sum[ (lam_i-1)^2 / (1 + h^2(lam_i - 1))^2 ]
#
# b = sum[ (lam_i - 1) / (1 + h^2(lam_i - 1)) ]
#
# var(h_hat^2) = 2 / (a - b^2/N)
#
# N = sample size

se_herit <-
    function(pheno, kinship)
{

    h2 <- as.numeric(est_herit(pheno, kinship))

    d <- decomp_kinship(kinship)

    lam <- d$values
    a <- sapply(h2, function(hsq) sum( (lam-1)^2 / (1 + hsq*(lam-1))^2 ) )
    b <- sapply(h2, function(hsq) sum( (lam-1) / (1 + hsq*(lam-1)) ) )
    n <- length(lam)

    setNames( sqrt(2 / (a - b^2/n)), colnames(pheno) )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant