# NOT RUN {
S <- cbind(diag(2), c(-1, 1), c(1.1, -1)) # inequality matrix
# S'x >= 0 represents the wedge x1 <= x2 <= 1.1 x1
# example taken from Pakman and Paninski (2014)
# 1. exact Hamiltonian Monte Carlo (Pakman and Paninski, 2014)
sampler <- create_TMVN_sampler(Q=diag(2), mu=c(4, 4), S=S, method="HMC")
sim <- MCMCsim(sampler)
summary(sim)
plot(as.matrix(sim$x), pch=".")
# 2. Gibbs sampling approach (Rodriguez-Yam et al., 2004)
sampler <- create_TMVN_sampler(Q=diag(2), mu=c(4, 4), S=S, method="Gibbs")
sim <- MCMCsim(sampler)
summary(sim)
plot(as.matrix(sim$x), pch=".")
# 3. soft TMVN approximation (Souris et al., 2018)
sampler <- create_TMVN_sampler(Q=diag(2), mu=c(4, 4), S=S, method="softTMVN")
sim <- MCMCsim(sampler)
summary(sim)
plot(as.matrix(sim$x), pch=".")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab