Heterogeneity Analysis: Shared Structured, Sharing by sign

data=readRDS("../../../Dropbox/simdata.rds")
t=data$tstat;bhat=data$betahat;sebetahat=data$sebetahat;beta=data$beta;v.j=matrix(rep(1,ncol(t)*nrow(t)),ncol=ncol(t),nrow=nrow(t))

mash.means=read.table("../../../Dropbox/simulationsmay12/shared/sharedashcutoffomega2jun15posterior.means.txt")[,-1]

bma.means=read.table("../../../Dropbox/simulationsmay12/shared/noashsharedwithzerobmaallposterior.means.txt")[,-1]

ash.means=read.table("../../../Dropbox/simulationsmay12/shared/univariate.ash.pm.txt")


lfsr.mash=read.table("../../../Dropbox/simulationsmay12/shared/sharedashcutoffomega2jun15lfsr.txt")[,-1]
lfsr.bma=read.table("../../../Dropbox/simulationsmay12/shared/noashsharedwithzerobmaalllfsr.txt")[,-1]
lfsr.ash=read.table("../../../Dropbox/simulationsmay12/shared/univariate.ash.lfsr.txt")



standard.error=data$sebetahat

pm.mash.beta=mash.means*standard.error
pm.bma.beta=bma.means*standard.error
pm.ash.beta=ash.means*standard.error

thresh=0.05

Here, we show the Proportion of Sharing by Sign:

sigmat=(lfsr.mash<=thresh)
nsig= rowSums(sigmat)
#(signall=mean(het.norm(pm.mash.beta[nsig>0,])>0))
(signall.mash=mean(het.norm(pm.mash.beta[1:400,])>0))
## [1] 0.7284659
##BMA
sigmat=(lfsr.bma<=thresh)
nsig= rowSums(sigmat)
#(signall=mean(het.norm(pm.bma.beta[nsig>0,])>0))
(signall.bma=mean(het.norm(pm.bma.beta[1:400,])>0))
## [1] 0.7469318
##ASH
sigmat=(lfsr.ash<thresh)
nsig= rowSums(sigmat)
#(signall=mean(het.norm(pm.ash.beta[nsig>0,])>0))
(signall.ash=mean(het.norm(pm.ash.beta[1:400,])>0))
## [1] 0.7119318
####SHow that results are robust in specific analysis

(truth=(mean(het.norm(data$beta[1:400,])>0)))
## [1] 0.7269318
(standard=mean(het.norm(data$betahat[1:400,])>0))
## [1] 0.7111364
(RMLE=sqrt(mean((standard-truth)^2)))
## [1] 0.01579545
#RMLE=1
(RRMSE.mash=sqrt(mean((signall.mash-truth)^2))/RMLE)
## [1] 0.0971223
(RRMSE.bma=sqrt(mean((signall.bma-truth)^2))/RMLE)
## [1] 1.266187
(RRMSE.ash=sqrt(mean((signall.ash-truth)^2))/RMLE)
## [1] 0.9496403
rmse.all.table=cbind(mash=RRMSE.mash,bmalite=RRMSE.bma,ash=RRMSE.ash)
barplot(as.numeric(rmse.all.table),main="Shared, Structured Effects: Sign heterogeneity",
        ylab="relative error (RRMSE)",xlab="Method",col=c("green","blue","red"),names=colnames(rmse.all.table),ylim=c(0,1.5),cex.main=1.5,cex.lab=1,cex.names=1,las=2)

Heterogeneity Analysis: Independent SSimulation by Sign

data=readRDS("../../../Dropbox/simulationsmarch9/independentsim/independentsim.rds")
t=data$tstat;bhat=data$betahat;sebetahat=data$sebetahat;beta=data$beta;v.j=matrix(rep(1,ncol(t)*nrow(t)),ncol=ncol(t),nrow=nrow(t))


mash.means=read.table("../../../Dropbox/simulationsmay12/independentsim_all/independentsimashcutoffomega2jun15posterior.means.txt")[,-1]
ash.means=read.table("../../../Dropbox/simulationsmay12/independentsim_all/univariate.ash.pmind.txt")

bma.means=read.table("../../../Dropbox/simulationsmay12/independentsim_all/noashindependentwithzerobmaallposterior.means.txt")[,-1]



lfsr.mash=read.table("../../../Dropbox/simulationsmay12/independentsim_all/independentsimashcutoffomega2jun15lfsr.txt")[,-1]
lfsr.bma=read.table("../../../Dropbox/simulationsmay12/independentsim_all/noashindependentwithzerobmaalllfsr.txt")[,-1]
lfsr.ash=read.table("../../../Dropbox/simulationsmay12/independentsim_all/univariate.ashind.lfsr.txt")




standard.error=data$sebetahat

pm.mash.beta=mash.means*standard.error
pm.bma.beta=bma.means*standard.error
pm.ash.beta=ash.means*standard.error

thresh=0.05

Here, we show the Proportion of Sharing by Sign:

sigmat=(lfsr.mash<=thresh)
nsig= rowSums(sigmat)
#(signall=mean(het.norm(pm.mash.beta[nsig>0,])>0))
(signall.mash=mean(het.norm(pm.mash.beta[1:400,])>0))
## [1] 0.5125
##BMA
sigmat=(lfsr.bma<=thresh)
nsig= rowSums(sigmat)
#(signall=mean(het.norm(pm.bma.beta[nsig>0,])>0))
(signall.bma=mean(het.norm(pm.bma.beta[1:400,])>0))
## [1] 0.5119886
##ASH
sigmat=(lfsr.ash<thresh)
nsig= rowSums(sigmat)
#(signall=mean(het.norm(pm.ash.beta[nsig>0,])>0))
(signall.ash=mean(het.norm(pm.ash.beta[1:400,])>0))
## [1] 0.5119886
(truth=(mean(het.norm(data$beta[1:400,])>0)))
## [1] 0.5127841
(standard=mean(het.norm(data$betahat[1:400,])>0))
## [1] 0.5107386
(RMLE=sqrt(mean((standard-truth)^2)))
## [1] 0.002045455
(RRMSE.mash=sqrt(mean((signall.mash-truth)^2))/RMLE)
## [1] 0.1388889
(RRMSE.bma=sqrt(mean((signall.bma-truth)^2))/RMLE)
## [1] 0.3888889
(RRMSE.ash=sqrt(mean((signall.ash-truth)^2))/RMLE)
## [1] 0.3888889
rmse.all.table=cbind(mash=RRMSE.mash,bmalite=RRMSE.bma,ash=RRMSE.ash)
barplot(as.numeric(rmse.all.table),main="Shared, Unstructured Effects: Sign heterogeneity",
        ylab="relative error (RRMSE)",xlab="Method",col=c("green","blue","red"),names=colnames(rmse.all.table),ylim=c(0,1.5),cex.main=1.5,cex.lab=1,cex.names=1,las=2)

Heterogeneity Analysis: Shared,Structured by magnitude

data=readRDS("../../../Dropbox/simdata.rds")
t=data$tstat;bhat=data$betahat;sebetahat=data$sebetahat;beta=data$beta;v.j=matrix(rep(1,ncol(t)*nrow(t)),ncol=ncol(t),nrow=nrow(t))

mash.means=read.table("../../../Dropbox/simulationsmay12/shared/sharedashcutoffomega2jun15posterior.means.txt")[,-1]
ash.means=read.table("../../../Dropbox/simulationsmay12/shared/univariate.ash.pm.txt")
bma.means=read.table("../../../Dropbox/simulationsmay12/shared/noashsharedwithzerobmaallposterior.means.txt")[,-1]



lfsr.mash=read.table("../../../Dropbox/simulationsmay12/shared/sharedashcutoffomega2jun15lfsr.txt")[,-1]
lfsr.bma=read.table("../../../Dropbox/simulationsmay12/shared/noashsharedwithzerobmaalllfsr.txt")[,-1]
lfsr.ash=read.table("../../../Dropbox/simulationsmay12/shared/univariate.ash.lfsr.txt")



standard.error=data$sebetahat

pm.mash.beta=mash.means*standard.error
pm.bma.beta=bma.means*standard.error
pm.ash.beta=ash.means*standard.error

thresh=0.05

Here, we show the Proportion of Sharing by Sign:

sigmat=(lfsr.mash<=thresh)
nsig= rowSums(sigmat)
(signall=mean(het.norm(pm.mash.beta[nsig>0,])>0.5))
## [1] 0.2848853
(signall.mash=mean(het.norm(pm.mash.beta[1:400,])>0.5))
## [1] 0.2440909
##BMA
sigmat=(lfsr.bma<=thresh)
nsig= rowSums(sigmat)
(signall=mean(het.norm(pm.bma.beta[nsig>0,])>0.5))
## [1] 0.3696412
(signall.bma=mean(het.norm(pm.bma.beta[1:400,])>0.5))
## [1] 0.2941477
##ASH
sigmat=(lfsr.ash<thresh)
nsig= rowSums(sigmat)
(signall=mean(het.norm(pm.ash.beta[nsig>0,])>0.5))
## [1] 0.1679426
(signall.ash=mean(het.norm(pm.ash.beta[1:400,])>0.5))
## [1] 0.1315909
####SHow that results are robust in specific analysis

(truth=(mean(het.norm(data$beta[1:400,])>0.5)))
## [1] 0.2479545
(standard=mean(het.norm(data$betahat[1:400,])>0.5))
## [1] 0.2152273
(RMLE=sqrt(mean((standard-truth)^2)))
## [1] 0.03272727
(RRMSE.mash=sqrt(mean((signall.mash-truth)^2))/RMLE)
## [1] 0.1180556
(RRMSE.bma=sqrt(mean((signall.bma-truth)^2))/RMLE)
## [1] 1.411458
(RRMSE.ash=sqrt(mean((signall.ash-truth)^2))/RMLE)
## [1] 3.555556
rmse.all.table=cbind(mash=RRMSE.mash,bmalite=RRMSE.bma,ash=RRMSE.ash)
barplot(as.numeric(rmse.all.table),main="Shared, Structured Effects: Magnitude heterogeneity",
        ylab="relative error (RRMSE)",xlab="Method",col=c("green","blue","red"),names=colnames(rmse.all.table),ylim=c(0,1.5),cex.main=1.5,cex.lab=1,cex.names=1,las=2)

Heterogeneity Analysis: Independent by magnitude

data=readRDS("../../../Dropbox/simulationsmarch9/independentsim/independentsim.rds")
t=data$tstat;bhat=data$betahat;sebetahat=data$sebetahat;beta=data$beta;v.j=matrix(rep(1,ncol(t)*nrow(t)),ncol=ncol(t),nrow=nrow(t))


mash.means=read.table("../../../Dropbox/simulationsmay12/independentsim_all/independentsimashcutoffomega2jun15posterior.means.txt")[,-1]
ash.means=read.table("../../../Dropbox/simulationsmay12/independentsim_all/univariate.ash.pmind.txt")

bma.means=read.table("../../../Dropbox/simulationsmay12/independentsim_all/noashindependentwithzerobmaallposterior.means.txt")[,-1]



lfsr.mash=read.table("../../../Dropbox/simulationsmay12/independentsim_all/independentsimashcutoffomega2jun15lfsr.txt")[,-1]
lfsr.bma=read.table("../../../Dropbox/simulationsmay12/independentsim_all/noashindependentwithzerobmaalllfsr.txt")[,-1]
lfsr.ash=read.table("../../../Dropbox/simulationsmay12/independentsim_all/univariate.ashind.lfsr.txt")




standard.error=data$sebetahat

pm.mash.beta=mash.means*standard.error
pm.bma.beta=bma.means*standard.error
pm.ash.beta=ash.means*standard.error

thresh=0.05

Here, we show the Proportion of Sharing by Sign:

sigmat=(lfsr.mash<=thresh)
nsig= rowSums(sigmat)
(signall=mean(het.norm(pm.mash.beta[nsig>0,])>0.5))
## [1] 0.1285795
(signall.mash=mean(het.norm(pm.mash.beta[1:400,])>0.5))
## [1] 0.1285795
##BMA
sigmat=(lfsr.bma<=thresh)
nsig= rowSums(sigmat)
(signall=mean(het.norm(pm.bma.beta[nsig>0,])>0.5))
## [1] 0.1288068
(signall.bma=mean(het.norm(pm.bma.beta[1:400,])>0.5))
## [1] 0.1288068
##ASH
sigmat=(lfsr.ash<thresh)
nsig= rowSums(sigmat)
(signall=mean(het.norm(pm.ash.beta[nsig>0,])>0.5))
## [1] 0.1233225
(signall.ash=mean(het.norm(pm.ash.beta[1:400,])>0.5))
## [1] 0.1283523
####SHow that results are robust in specific analysis

(truth=(mean(het.norm(data$beta[1:400,])>0.5)))
## [1] 0.1277841
(standard=mean(het.norm(data$betahat[1:400,])>0.5))
## [1] 0.1286932
(RMLE=sqrt(mean((standard-truth)^2)))
## [1] 0.0009090909
(RRMSE.mash=sqrt(mean((signall.mash-truth)^2))/RMLE)
## [1] 0.875
(RRMSE.bma=sqrt(mean((signall.bma-truth)^2))/RMLE)
## [1] 1.125
(RRMSE.ash=sqrt(mean((signall.ash-truth)^2))/RMLE)
## [1] 0.625
rmse.all.table=cbind(mash=RRMSE.mash,bmalite=RRMSE.bma,ash=RRMSE.ash)
barplot(as.numeric(rmse.all.table),main="Shared, Untructured Effects: Sign heterogeneity",
        ylab="relative error (RRMSE)",xlab="Method",col=c("green","blue","red"),names=colnames(rmse.all.table),ylim=c(0,1.5),cex.main=1.5,cex.lab=1,cex.names=1,las=2)