stephenslab / ebnm

R package to fit Empirical Bayes Normal Means model.
https://stephenslab.github.io/ebnm/
12 stars 9 forks source link

throw warning when mode = 0 for ebnm_point_mass #118

Closed willwerscheid closed 4 months ago

willwerscheid commented 4 months ago

From Joon:

I’ve been trying the ebnm::ebnm_point_mass function, and was not getting an expected result. After reading the documentation, I found out that it was due to the setting that the default value for mode is 0, not 'estimate'. I see this default might be intended since tests/testthat/test_point_mass.R expects the default output to produce posteriors of point mass at zero. Still, I wanted to suggest considering changing the default to 'estimate' because users might not expect or necessarily desire a result of point masses at zero when using the ebnm::ebnm_point_mass function.

willwerscheid commented 4 months ago

@joonsukkang Here is the warning that I have added. Does this look better to you?

> x <- rnorm(100, 0, 2)
> res <- ebnm_point_mass(x)
Warning message:
In ebnm_workhorse(x = x, s = s, mode = mode, scale = 0, g_init = g_init,  :
  For consistency with other prior families, the location of the prior point mass is fixed at zero. If this behavior is desired, set argument mode = 0 to bypass this warning. Set mode = 'estimate' to instead estimate the point mass.
> res <- ebnm_point_mass(x, mode = 0)
> res <- ebnm_point_mass(x, mode = "estimate")
joonsukkang commented 4 months ago

Yes, it looks clear and actionable!