# NOT RUN {
##################################################
## please see vignette and/or www.rob-mcculloch.org for more realistic examples
##################################################
## get simulated data
data(simdat)
##get rbart run on the simulated data
data(rbartonsimd)
## plot function (f and s) draws
shat = sqrt(mean((simdat$yp-rbartonsimd$mmean)^2)) #overall estimate of sigma
lmfit = lm(y~x,data.frame(x=simdat$x,y=simdat$y))
yhatlm = predict(lmfit,data.frame(x=simdat$xp)) #fits from a linear model
#Now we use plotFunctionDraws to look at mdraws (left panel) and sdraws (right panel).
## in the mean inference, you can see that the linear model seem unlikely
## in the variance inference, you can see that the posteriors of s(x) are far from a constant value
par(mfrow=c(1,2))
## look at mean inference
plotFunctionDraws(rbartonsimd$mdraws,complevel=mean(simdat$y), probs=c(.05,.95),
xlab=expression(hat(f)(x)), pts=yhatlm, ptscol="black",
cex.lab=1.2, cex.axis=1.4, main="intervals for f(x)")
##look at the standard deviation inference
plotFunctionDraws(rbartonsimd$sdraws, complevel=shat, xlab=expression(hat(s)(x)),
intervalcol="magenta", linecol="blue",
cex.lab=1.2, cex.axis=1.4, main="intervals for s(x)")
# }
Run the code above in your browser using DataLab