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

Liability-Threshold Model #178

Open
gaynorr opened this issue Feb 6, 2024 · 0 comments
Open

Liability-Threshold Model #178

gaynorr opened this issue Feb 6, 2024 · 0 comments
Assignees

Comments

@gaynorr
Copy link
Owner

gaynorr commented Feb 6, 2024

At a minimum, make script liability-threshold model available in AlphaSimR discussions thread. Better yet, role this functionality into AlphaSimR directly. Script is below.

# Based on the liability-threshold model

library(AlphaSimR)

prevelance = 0.95
varG = 1
H2 = 0.2

# Calculate varE
varE = varG/H2 - varG

# Calculate truncation point
t = qnorm(prevelance, sd=sqrt(varG+varE),lower.tail=F)
phenoTL = function(Y,whichTrait=1,trunc=t){
  return(Y[,whichTrait,drop=FALSE]>trunc)
}


founderPop = quickHaplo(1000, 10, 1000)

SP = SimParam$
  new(founderPop)$
  addTraitA(1000,var=varG)$
  setVarE(H2=H2)

pop = newPop(founderPop)
meanO = meanL = numeric(20)

for(i in 1:20){
  pop = selectCross(pop,100,trait=phenoTL,nCrosses=1000)
  meanO[i] = mean(phenoTL(pop@pheno))
  meanL[i] = meanG(pop)
}
meanO
meanL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant