library(MCMCpack)
draw <- rwish(3, matrix(c(1,.3,.3,1),2,2))
nsim<-1000
store22<-store21<-store12<-store11<-rep(NA,nsim)
for(i in 1:nsim){
draw <- rwish(3, matrix(c(1,0.9,0.9,1),2,2))
store11[i]<-draw[1,1]
store12[i]<-draw[1,2]
store21[i]<-draw[2,1]
store22[i]<-draw[2,2]
}
library(MASS)
variances<-as.matrix(data.frame(store11,store22))
bivn.kde<-kde2d(variances[,1],variances[,2],n=nsim)
persp(bivn.kde,phi=10,theta=0,shade=0.2,border=NA,
main="Simulated variances' joint distribution")
My Stan related question is: I want to have something simple like this for lkj_corr(2.0), lkj_corr(0.5), and lkj_corr(2.0). Does this make sense:
## Stan and R code:
omegamodel<- '
parameters {
corr_matrix[2] Omega;
}
model {
// vary the parameter: set it to 0.5, 1.0, 2.0
// to see the shape change
Omega ~ lkj_corr(1.0);
}
'
library(rstan)
set_cppo("fast")
fit <- stan(model_code = omegamodel,
iter = 500, chains = 2)
print(fit)
fit2<-as.matrix(fit)
offdiags<-fit2[,c(2,3)]
bivn.kde<-kde2d(offdiags[,1],offdiags[,2],
n=500)
persp(bivn.kde,phi=10,theta=0,shade=0.2,border=NA,
main="Simulated lkj_corr joint distribution")
--
Shravan Vasishth
Professor for Psycholinguistics und Neurolinguistics