Closed cecileane closed 3 years ago
I believe you're correct! Line 92 of phylopars_main.R (version 0.2.11) reads:
X[[j]][1:ntaxa + (jj-1)(ntaxa),] <- simdat_j[,1:ntraitsjj]
but it should be
X[[j]][1:ntaxa + (jj-1)(ntaxa),] <- simdat_j[,(1:ntraits-1)nreps+jj]
I believe this will correct the problem. For the example above, the revised function gives:
species V1 V2
1 A -0.2308539 -2.039187
2 B 0.4964587 -1.314626
3 C -0.6836476 6.144626
4 A -0.2308427 -2.039195
5 B 0.4964704 -1.314642
6 C -0.6836453 6.144635
This will be included in version >=0.2.12. Thanks for catching this!
Thank you for your diagnosis and fix, Eric!
I am afraid there is a bug with the simulation function, when
nreps
is more than 1. Example below, with a 3-taxon tree, 2 independent traits, both with very small within-species variation to see the problem.Now to the simulation:
It looks good so far: V1 and V2 have "reasonable" simulated species means. The problem comes next. The individual values are good for V1: each individual has a value almost equal to the species mean (up the the 5th decimal point, because of within-species variance of 1e-10). But the second variable V2 seems to be messed up: