View source: R/BayesMultMeta.R
| MC_ranks | R Documentation |
The function computes the ranks within the pooled draws of Markov chains. Average ranks are used for ties.
MC_ranks(MC)
MC |
An N \times M matrix with N draws in each of M constructed Markov chains. |
a matrix with the ranks from the MCMC procedure
dataREM<-mvmeta::hyp
# Observation matrix X
X<-t(cbind(dataREM$sbp,dataREM$dbp))
p<-nrow(X) # model dimension
n<-ncol(X) # sample size
# Matrix U
U<-matrix(0,n*p,n*p)
for (i_n in 1:n) {
Use<-diag(c(dataREM$sbp_se[i_n],dataREM$dbp_se[i_n]))
Corr_mat<-matrix(c(1,dataREM$rho[i_n],dataREM$rho[i_n],1),p,p)
U[(p*(i_n-1)+1):(p*i_n),(p*(i_n-1)+1):(p*i_n)]<- Use%*%Corr_mat%*%Use
}
# Generating M Markov chains for mu_1
M<-4 # number of chains
MC <-NULL
for (i in 1:M) {
chain <- BayesMultMeta(X, U, 1e2, burn_in = 1e2,
likelihood = "t", prior="jeffrey",
algorithm_version = "mu",d=3)
MC<- cbind(MC,chain$mu[1,])
}
ranks<-MC_ranks(MC)
id_chain <- 1
hist(ranks[,id_chain],breaks=25,prob=TRUE, labels = FALSE, border = "dark blue",
col = "light blue", main = expression("Chain 1,"~mu[1]), xlab = expression(),
ylab = expression(),cex.axis=1.2,cex.main=1.7,font=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.