# we define the inputs
# nimp, nburn and nbetween are smaller than they should. This is
#just because of CRAN policies on the examples.
Y<-cldata[,c("measure","age")]
clus<-cldata[,c("city")]
X=data.frame(rep(1,1000),cldata[,c("sex")])
colnames(X)<-c("const", "sex")
Z<-data.frame(rep(1,1000))
beta.start<-matrix(0,2,2)
u.start<-matrix(0,10,2)
l1cov.start<-matrix(diag(1,2),20,2,2)
l2cov.start<-diag(1,2)
l1cov.prior=diag(1,2);
nburn=as.integer(50);
nbetween=as.integer(20);
nimp=as.integer(5);
l2cov.prior=diag(1,5);
a=3
# Finally we run either the model with fixed or random cluster-specific covariance matrices:
imp<-jomo1ranconhr(Y,X,Z,clus,beta.start,u.start,l1cov.start, l2cov.start,
l1cov.prior,l2cov.prior,nburn,nbetween,nimp,meth="fixed")
cat("Original value was missing(",imp[4,1],"), imputed value:", imp[1004,1])
#or:
#imp<-jomo1ranconhr(Y,X,Z,clus,beta.start,u.start,l1cov.start, l2cov.start,
# l1cov.prior,l2cov.prior,nburn,nbetween,nimp,a,meth="random")
# Check help page for function jomo to see how to fit the model and
# combine estimates with Rubin's rules
Run the code above in your browser using DataLab