## Not run:
# ####################################
# # Univariate example
# ####################################
#
# # Data
# data(galaxy)
# galaxy <- data.frame(galaxy,speeds=galaxy$speed/1000)
# attach(galaxy)
#
# # Initial state
# state <- NULL
#
# # MCMC parameters
#
# nburn <- 1000
# nsave <- 10000
# nskip <- 10
# ndisplay <- 100
# mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay)
#
# # Example of Prior information 1
# # Fixing alpha, m1, and Psi1
#
# prior1 <- list(alpha=1,m1=rep(0,1),psiinv1=diag(0.5,1),nu1=4,
# tau1=1,tau2=100)
#
#
# # Example of Prior information 2
# # Fixing alpha and m1
#
# prior2 <- list(alpha=1,m1=rep(0,1),psiinv2=solve(diag(0.5,1)),
# nu1=4,nu2=4,tau1=1,tau2=100)
#
#
# # Example of Prior information 3
# # Fixing only alpha
#
# prior3 <- list(alpha=1,m2=rep(0,1),s2=diag(100000,1),
# psiinv2=solve(diag(0.5,1)),
# nu1=4,nu2=4,tau1=1,tau2=100)
#
#
# # Example of Prior information 4
# # Everything is random
#
# prior4 <- list(a0=2,b0=1,m2=rep(0,1),s2=diag(100000,1),
# psiinv2=solve(diag(0.5,1)),
# nu1=4,nu2=4,tau1=1,tau2=100)
#
# # Fit the models
#
# fit1.1 <- DPdensity(y=speeds,prior=prior1,mcmc=mcmc,
# state=state,status=TRUE)
# fit1.2 <- DPdensity(y=speeds,prior=prior2,mcmc=mcmc,
# state=state,status=TRUE)
# fit1.3 <- DPdensity(y=speeds,prior=prior3,mcmc=mcmc,
# state=state,status=TRUE)
# fit1.4 <- DPdensity(y=speeds,prior=prior4,mcmc=mcmc,
# state=state,status=TRUE)
#
# # Posterior means
# fit1.1
# fit1.2
# fit1.3
# fit1.4
#
# # Plot the estimated density
# plot(fit1.1,ask=FALSE)
# plot(fit1.2,ask=FALSE)
# plot(fit1.3,ask=FALSE)
# plot(fit1.4,ask=FALSE)
#
# # Extracting the density estimate
# cbind(fit1.1$x1,fit1.1$dens)
# cbind(fit1.2$x1,fit1.2$dens)
# cbind(fit1.3$x1,fit1.3$dens)
# cbind(fit1.4$x1,fit1.4$dens)
#
# # Plot the parameters (only prior 2 for illustration)
# # (to see the plots gradually set ask=TRUE)
# plot(fit1.2,ask=FALSE,output="param")
#
# # Plot the a specific parameters
# # (to see the plots gradually set ask=TRUE)
# plot(fit1.2,ask=FALSE,output="param",param="psi1-speeds",
# nfigr=1,nfigc=2)
#
# # Extracting the posterior mean of the specific
# # means and covariance matrices
# # (only prior 2 for illustration)
# DPrandom(fit1.2)
#
# # Ploting predictive information about the specific
# # means and covariance matrices
# # with HPD and Credibility intervals
# # (only prior 2 for illustration)
# # (to see the plots gradually set ask=TRUE)
# plot(DPrandom(fit1.2,predictive=TRUE),ask=FALSE)
# plot(DPrandom(fit1.2,predictive=TRUE),ask=FALSE,hpd=FALSE)
#
# # Ploting information about all the specific means
# # and covariance matrices
# # with HPD and Credibility intervals
# # (only prior 2 for illustration)
# # (to see the plots gradually set ask=TRUE)
# plot(DPrandom(fit1.2),ask=FALSE,hpd=FALSE)
#
#
# ####################################
# # Bivariate example
# ####################################
#
# # Data
# data(airquality)
# attach(airquality)
#
# ozone <- Ozone**(1/3)
# radiation <- Solar.R
#
# # Prior information
#
# s2 <- matrix(c(10000,0,0,1),ncol=2)
# m2 <- c(180,3)
# psiinv2 <- solve(matrix(c(10000,0,0,1),ncol=2))
#
# prior <- list(a0=1,b0=1/5,nu1=4,nu2=4,s2=s2,
# m2=m2,psiinv2=psiinv2,tau1=0.01,tau2=0.01)
#
# # Initial state
# state <- NULL
#
# # MCMC parameters
#
# nburn <- 5000
# nsave <- 10000
# nskip <- 10
# ndisplay <- 1000
# mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay)
#
# # Fit the model
# fit1 <- DPdensity(y=cbind(radiation,ozone),prior=prior,mcmc=mcmc,
# state=state,status=TRUE,na.action=na.omit)
#
# # Plot the estimated density
# plot(fit1)
#
# # Extracting the density estimate
# fit1$x1
# fit1$x2
# fit1$dens
# ## End(Not run)
Run the code above in your browser using DataLab