mtag icon indicating copy to clipboard operation
mtag copied to clipboard

Mistake in computing mtag factor?

Open hmkweon opened this issue 4 years ago • 1 comments

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

hmkweon avatar Apr 24 '20 22:04 hmkweon

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.

paturley avatar May 04 '20 14:05 paturley