library (rsm)
heli.rsm = rsm (ave ~ block + SO(x1, x2, x3, x4), data = heli)
# Plain contour plots
par (mfrow = c (2,3))
contour (heli.rsm, ~x1+x2+x3+x4, at=canonical(heli.rsm)$xs)
# Same with image overlay and extra annotations showing
# stationary point and "at" values
# Demonstrates use of 'hook' argument
xs = canonical(heli.rsm)$xs
myhook = list()
myhook$post.plot = function(lab) {
idx = sapply(lab[3:4], grep, names(xs))
points (xs[idx[1]], xs[idx[2]], pch=2, col="red")
main = paste("Predicted response versus", lab[3], "and", lab[4])
atlabs = paste(names(xs[-idx]), round(xs[-idx], 3), sep = "= ")
atlabs = paste(atlabs, collapse = ", ")
title(c(main, paste("at", atlabs)))
}
contour (heli.rsm, ~x1+x2+x3+x4, at=xs, hook=myhook, image=TRUE)
# Default perspective views
persp (heli.rsm, ~x1+x2+x3+x4, at=canonical(heli.rsm)$xs)
# Same plots, souped-up with facet coloring and axis labeling
persp (heli.rsm, ~x1+x2+x3+x4, contours="col", col=rainbow(40), at=canonical(heli.rsm)$xs,
xlabs = c("Wing area", "Wing length", "Body width", "Body length"), zlab = "Flight time")
### Hints for creating graphics files for use in publications...
# Save perspective plots in one PDF file (will be six pages long)
pdf(file = "heli-plots.pdf")
persp (heli.rsm, ~x1+x2+x3+x4, at=canonical(heli.rsm)$xs)
dev.off()
# Save perspective plots in six separate PNG files
png.hook = list()
png.hook$pre.plot = function(lab)
png(file = paste(lab[3], lab[4], ".png", sep = ""))
png.hook$post.plot = function(lab)
dev.off()
persp (heli.rsm, ~x1+x2+x3+x4, at=canonical(heli.rsm)$xs, hook = png.hook)
Run the code above in your browser using DataLab