y=c(4, 18, 40, 130)
nv=c(13, 83, 60,166)
require(partitions)
out=metabup(y, nv, type=1)
#estimates
out[1]
#the partitions with the largest posterior p(g|y)
out[2:3]
#plotting similarity matrix
require(ggplot2)
L=length(y)
indmat=matrix(unlist(out[4]),ncol=L, byrow=FALSE)
psingle<-rep(0,L)
sim_mat<-indmat +t(indmat)
diag(sim_mat)<-psingle #rep(1,L)
xy=expand.grid(x=1:L, y=1:L)
index=as.vector( sim_mat)
mat_data = cbind(xy,index)
brlab<-round(seq(0, max(sim_mat)+0.05, length.out=4),2)
p <- ggplot(data = mat_data) + # Set data
geom_tile(aes(x = x, y = y, fill =index)) +
scale_fill_gradientn(colours=rev(heat.colors(5)),na.value = "transparent",
breaks=brlab,labels=brlab,
limits=c(0,max(sim_mat)+0.075))+
scale_x_continuous(name="Study Number", breaks=1:L, limits=c(0.5,+L+0.5)) +
scale_y_continuous(name="", breaks=1:L, limits=c(0.5,L+0.5))
p + theme(axis.title = element_text() )
ph=c(31, 21.7, 66.7,78.3)/100
y=log(ph/(1-ph))
n=c(13, 83, 60,166)
nv=1/(ph*(1-ph)*n) #variance
require(partitions)
out=metabup(y, nv)
#estimates
out[1]
#the partitions with the largest posterior p(g|y)
out[2:3]
#plotting similarity matrix
require(ggplot2)
L=length(y)
indmat=matrix(unlist(out[4]),ncol=L, byrow=FALSE)
psingle<-rep(0,L)
sim_mat<-indmat +t(indmat)
diag(sim_mat)<-psingle #rep(1,L)
xy=expand.grid(x=1:L, y=1:L)
index=as.vector( sim_mat)
mat_data = cbind(xy,index)
brlab<-round(seq(0, max(sim_mat)+0.05, length.out=4),2)
p <- ggplot(data = mat_data) + # Set data
geom_tile(aes(x = x, y = y, fill =index)) +
scale_fill_gradientn(colours=rev(heat.colors(5)),na.value = "transparent",
breaks=brlab,labels=brlab,
limits=c(0,max(sim_mat)+0.075))+
scale_x_continuous(name="Study Number", breaks=1:L, limits=c(0.5,+L+0.5)) +
scale_y_continuous(name="", breaks=1:L, limits=c(0.5,L+0.5))
p + theme(axis.title = element_text() )
Run the code above in your browser using DataLab