Closed gregorgorjanc closed 2 years ago
It will accept a covariance matrix. I just need to tidy up some documentation. I'll leave this open as a reminder to myself.
library(AlphaSimR)
founderPop = quickHaplo(50, 10, 100)
SP = SimParam$
new(founderPop)$
addTraitA(100, mean=c(0,0), var=c(1,1))$
setVarE(varE=0.5*diag(2)+0.5)
pop = newPop(founderPop)
cor(pheno(pop)-gv(pop))
Ah, great!
May I suggest alignment of arguments with functions for adding traits (genetic part) - var and cor, hmm do we have var and corA there?
No, this function doesn't touch the genetic variances at all.
The correlation part is inconsistent in how it is being handled for genetic effects and error. You can current supply a vector of variances to varE or a covariance matrix. For h2 and H2, you can only supply a vector. When a vector has been supplied, you can convert it to a covariance matrix by supplying correlations to a separate function in SimParam called setCorE. I should probably drop this function and instead have correlations as an option in setVarE. This would be more consistent with how correlated traits are handled.
Is my reading correct that
SimParam$setVarE()
accepts only a vector of environmental variances and not a full covariance matrix, while adding a trait (genetic part) enables adding a full covariance matrix?The help page says "varE a vector or matrix of error variances".
In
setPheno()
the help page says "varE error (co)variances for traits. See details."