Last chance! 50% off unlimited learning
Sale ends in
jomo1ranmix.MCMCchain(Y_con, Y_cat, Y_numcat, X=matrix(1,nrow(Y_cat),1),
Z=matrix(1,nrow(Y_cat),1), clus,
betap=matrix(0,ncol(X),(ncol(Y_con)+(sum(Y_numcat)-length(Y_numcat)))),
up=matrix(0,nrow(unique(clus)),ncol(Z)*(ncol(Y_con)+(sum(Y_numcat)-length(Y_numcat)))),
covp=diag(1,ncol(betap)), covu=diag(1,ncol(up)),
Sp=diag(1,ncol(covp)), Sup=diag(1,ncol(covu)), nburn=100, output=1, out.iter=10)
#First of all we load and attach the data:
data(mldata)
attach(mldata)
#Then we define the inputs:
# nimp, nburn and nbetween are smaller than they should. This is
#just because of CRAN policies on the examples.
Y_con=data.frame(measure,age)
Y_cat=data.frame(social)
Y_numcat=matrix(4,1,1)
X=data.frame(rep(1,1000),sex)
Z<-data.frame(rep(1,1000))
clus<-data.frame(city)
betap<-matrix(0,2,5)
up<-matrix(0,10,5)
covp<-diag(1,5)
covu<-diag(1,5)
Sp=diag(1,5);
Sup=diag(1,5);
nburn=as.integer(100);
#Then we can run the sampler:
imp<-jomo1ranmix.MCMCchain(Y_con, Y_cat, Y_numcat, X,Z,clus,betap,up,covp, covu,Sp,Sup,nburn)
#We can check the convergence of the first element of beta:
plot(c(1:nburn),imp$collectbeta[1,1,1:nburn],type="l")
#Or similarly we can check the convergence of any element of th elevel 2 covariance matrix:
plot(c(1:nburn),imp$collectcovu[1,2,1:nburn],type="l")
Run the code above in your browser using DataLab