mtag
mtag copied to clipboard
Mistake in computing mtag factor?
Hi,
There seems to be a mistake in the code for computing mtag factors reported in the log. I've always been puzzled by weird weights reported by MTAG and noticed that the reported weights seems to be wrong given the estimated sigma and omega (while the final sumstat results are fine). I am not a frequent python user and do not fully understand np.einsum, but I seem to get correct weights with the following changes.
This is about 'mtag_analysis' function starting from the line 780 of mtag.py. As far as I understand, MTAG produces T sets of T weights (with T being the number of traits). So, the mtag factor array should be defined by shape (M,P,P) instead of (M,P), which seems to be why MTAG only reports one set of weights. And this line
mtag_factor[:,p] = np.einsum('mp,m->m',np.einsum('q,mqp->mp',yy,inv_xx), 1/beta_denom)
needs to be replaced with
mtag_factor[:,p,:] = np.einsum('mp,m->mp',np.einsum('q,mqp->mp',yy,inv_xx), 1./beta_denom)
And with this change, the line 889 needs to change from _,P = mtag_factor.shape to _,_,P = mtag_factor.shape
Best, Hermon
Thanks for pointing this out, Hermon! This have been a bit busy for the last couple weeks with some grant deadlines, but we will look into this soon.