# Image and contour plots (These are Owww-Ahhh plots)
opar <- par(ask = interactive() && .Device == "X11")
data(volcano)
x <- 10 * (1:nrow(volcano))
x.at <- seq(100, 800, by = 100)
y <- 10 * (1:ncol(volcano))
y.at <- seq(100, 600, by = 100)
image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
rx <- range(x <- 10*1:nrow(volcano))
ry <- range(y <- 10*1:ncol(volcano))
ry <- ry + c(-1,1) * (diff(rx) - diff(ry))/2
tcol <- terrain.colors(12)
par(opar); par(mfrow=c(1,1)); opar <- par(pty = "s", bg = "lightcyan")
plot(x = 0, y = 0,type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
u <- par("usr")
rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")
contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE)
title("A Topographic Map of Maunga Whau", font = 4)
abline(h = 200*0:4, v = 200*0:4, col = "lightgray", lty = 2, lwd = 0.1)
par(opar)
a sample code using sem package, originally posted by Mitsuo Igarashi [fpr 2411]
library(sem)
# lower triangle of covariance matrix
data.cov <- matrix(c(
0.862, 0, 0, 0, 0, 0,
0.489, 1.089, 0, 0, 0, 0,
-0.056, -0.189, 0.606, 0, 0, 0,
-0.122, -0.222, 0.406, 0.606, 0, 0,
0.016, -0.044, -0.089, -0.022, 0.262, 0,
0.067, 0.133, -0.200, -0.167, 0.200, 0.533
), ncol=6, byrow=T)
rownames(data.cov) <- colnames(data.cov) <- c('V1', 'V2', 'V3', 'V4', 'V5', 'V6')
# symbolic 'ram'
data.model <- matrix(c(
'F1 -> V1', 'a1', NA,
'F1 -> V2', 'a1', NA,
'F2 -> V3', 'a2', NA,
'F2 -> V4', 'a2', NA,
'F3 -> V5', 'a3', NA,
'F3 -> V6', 'a3', NA,
'V1 <-> V1', 'e1', NA,
'V2 <-> V2', 'e1', NA,
'V3 <-> V3', 'e2', NA,
'V4 <-> V4', 'e2', NA,
'V5 <-> V5', 'e3', NA,
'V6 <-> V6', 'e3', NA,
'F1 <-> F1', NA, 1,
'F2 <-> F2', NA, 1,
'F3 <-> F3', NA, 1,
'F1 <-> F2', 'f12', NA,
'F2 <-> F3', 'f23', NA,
'F1 <-> F3', 'f13', NA
), ncol=3, byrow=T)
data.sem <- sem(data.model, data.cov, 30)
summary(data.sem)