stephens999 / ashr

An R package for adaptive shrinkage
GNU General Public License v3.0
79 stars 35 forks source link

Posterior means are negative from binomial likelihood using logit link #99

Closed DongyueXie closed 5 years ago

DongyueXie commented 5 years ago

Example:

p = rbeta(100,2,2) # prior mode: 0.5 n = rpois(100,10) y = rbinom(100,n,p) # simulate Binomial observations fit=ash(rep(0,length(y)),1,lik=lik_binom(y,n,link='logit')) fit$result$PosteriorMean

Returned values are all negative.

stephens999 commented 5 years ago

I cannot duplicate this. what seed do you use? what version of ashr?

DongyueXie commented 5 years ago

I tried different seeds but this does not really matter. I'm usng version 2.2-7. Maybe this version is way outdated?

set.seed(12345) p = rbeta(100,2,2) # prior mode: 0.5 n = rpois(100,10) y = rbinom(100,n,p) # simulate Binomial observations fit=ash(rep(0,length(y)),1,lik=lik_binom(y,n,link='logit')) round(fit$result$PosteriorMean,2) [1] -0.50 -0.52 -0.52 -0.52 -0.52 -0.28 -0.52 -0.51 -0.52 -0.50 -0.52 -0.42 -0.51 -0.52 -0.52 -0.52 [17] -0.50 -0.50 -0.37 -0.52 -0.51 -0.39 -0.51 -0.25 0.00 -0.52 -0.52 -0.52 -0.52 -0.52 -0.52 -0.50 [33] -0.52 -0.51 -0.52 -0.46 -0.27 -0.51 -0.50 -0.46 -0.52 -0.52 -0.52 -0.51 -0.02 -0.52 -0.52 -0.43 [49] -0.52 -0.32 -0.52 -0.52 -0.51 -0.52 -0.50 -0.49 -0.02 -0.36 -0.52 -0.28 -0.52 -0.48 -0.52 -0.10 [65] -0.51 -0.52 -0.52 -0.52 -0.51 -0.42 -0.16 -0.50 -0.52 -0.52 -0.36 -0.52 -0.48 -0.51 -0.48 -0.52 [81] -0.06 -0.51 -0.50 -0.52 -0.45 -0.52 -0.51 -0.51 -0.52 -0.52 -0.51 -0.52 -0.51 -0.06 -0.48 -0.43 [97] -0.52 -0.35 -0.50 -0.03

pcarbo commented 5 years ago

@DongyueXie Yes, it is---on CRAN it is 2.2-32. Try upgrading and see if you get the same issue.

DongyueXie commented 5 years ago

The newest version does not have this problem. Thanks!