# NOT RUN {
# School Girls Data Example
data(schoolgirls)
attach(schoolgirls)
# Prior information
prior<-list(alpha=1,nu0=4.01,tau1=0.01,tau2=0.01,
tinv=diag(10,2),mub=rep(0,2),Sb=diag(1000,2))
# Initial state
state <- NULL
# MCMC parameters
nburn<-5000
nsave<-10000
nskip<-20
ndisplay<-1000
mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay)
# Fit the model: First run
fit1<-DPlmm(fixed=height~1,random=~age|child,prior=prior,mcmc=mcmc,
state=state,status=TRUE)
fit1
# Fit the model: Continuation
state<-fit1$state
fit2<-DPlmm(fixed=height~1,random=~age|child,prior=prior,mcmc=mcmc,
state=state,status=FALSE)
fit2
# Summary with HPD and Credibility intervals
summary(fit2)
summary(fit2,hpd=FALSE)
# Plot model parameters
# (to see the plots gradually set ask=TRUE)
plot(fit2,ask=FALSE)
plot(fit2,ask=FALSE,nfigr=2,nfigc=2)
# Plot an specific model parameter
# (to see the plots gradually set ask=TRUE)
plot(fit2,ask=FALSE,nfigr=1,nfigc=2,param="sigma-(Intercept)")
plot(fit2,ask=FALSE,nfigr=1,nfigc=2,param="ncluster")
# }
Run the code above in your browser using DataLab