stephenslab / mashr

An R package for multivariate adaptive shrinkage.
https://stephenslab.github.io/mashr
Other
88 stars 19 forks source link

Data dimension issue with usepointmass = FALSE #62

Open vplagnol opened 5 years ago

vplagnol commented 5 years ago

I am trying to use the usepointmass = FALSE option in mashr. Following the vignette using training/test datasets, I see

m = mash(data_random, Ulist = c(U.ed,U.c), outputlevel = 1, usepointmass = FALSE)
Actual model fit using random data
 - Computing 300000 x 954 likelihood matrix.

So far so good. But... my next call is:

  m2 = mashr::mash(full_data_mash,
+                          g=get_fitted_g(m),
+                          fixg=TRUE)
 - Computing 1000 x 955 likelihood matrix.
 - Likelihood calculations took 1.25 seconds.
 - Computing posterior matrices.
 - Computation allocated took 0.45 seconds.
Error in exp(lm$loglik_matrix) %*% pi_s : non-conformable arguments

The issue being the 955/954 discrepancy. But I cannot specify usepointmass = FALSE and a fixed g either:

 m2 = mashr::mash(full_data_mash,
+                          g=get_fitted_g(m),
+                          fixg=TRUE,
+                          usepointmass =FALSE)
Error in mashr::mash(full_data_mash, g = get_fitted_g(m), fixg = TRUE,  :
  cannot supply both g and usepointmass

It seems to me something is off in the code? It may be an easy fix.

vplagnol commented 5 years ago

As an update simply commenting this line ##if(!missing(usepointmass)){stop("cannot supply both g and usepointmass")} allows the code to run but I still get lfsr close to 1, which I think should not be happening if the point mass on 0 is not used. So while the modified code runs, I suspect the usepointmass behaviour is actually not happening.

gaow commented 5 years ago

@vplagnol sorry see the patch above -- would you test again? It should have fixed it.

vplagnol commented 5 years ago

Thanks @gaow . This indeed makes the code run, so many thanks for this.

Now does mashr do what I thought it would? Not sure. I have:

 get_fitted_g(m)$usepointmass
[1] FALSE

And I run:

m2 = mash(full_data_mash,
                  g=get_fitted_g(m),
                  fixg=TRUE)

I still see very high values for lfsr:

table( get_lfsr(m2)[,1] > 0.8)

FALSE  TRUE
  164   836

I thought that such lfsr would be bound to 0.5 in the absence of a point mass. And similarly, the posterior means are still very much shrunk to 0.

I thought that not using the point mass would change that behaviour?

It may be a different issue to raise, or me not understanding how the model works. But I am not sure I am really running mash without a point mass.

stephens999 commented 5 years ago

What is g$grid?

I wonder if it includes a zero anyway...?

On Wed, Apr 24, 2019, 22:21 Vincent Plagnol notifications@github.com wrote:

Thanks @gaow https://github.com/gaow . This indeed makes the code run, so many thanks for this.

Now does mashr do what I thought it would? Not sure. I have:

get_fitted_g(m)$usepointmass [1] FALSE

And I run:

m2 = mash(full_data_mash, g=get_fitted_g(m), fixg=TRUE)

I still see very high values for lfsr:

table( get_lfsr(m2)[,1] > 0.8)

FALSE TRUE 164 836

I thought that such lfsr would be bound to 0.5 in the absence of a point mass. And similarly, the posterior means are still very much shrunk to 0.

I thought that not using the point mass would change that behaviour?

It may be a different issue to raise, or me not understanding how the model works. But I am not sure I am really running mash without a point mass.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stephenslab/mashr/issues/62#issuecomment-486523521, or mute the thread https://github.com/notifications/unsubscribe-auth/AANXRRIQNBBEHRQAPSR66D3PSE5VVANCNFSM4HIH4CTA .