# # ### Fun with Graphing small but complex models. # # Also demonstrates some interesting ways # variables can be related. # ####################################### x <- seq(1:100)/10 z <- x^2 + x y <- x + 5 plot(x, y, cex = z, col="blue") plot(jitter(x), jitter(y), cex = jitter(z), col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- (seq(1:100)/10)*-1 z <- (x^2) y <- z + 5 plot(x, y, cex = z, col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- (seq(1:100)/10)*-1 z <- (x^2) y <- x + 5 plot(x, y, cex = z, col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- (seq(1:100)/10) z <- (x^3) y <- (x + 5)*-1 plot(x, y, cex = z, col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ############################## x <- seq(1:100)/10 z <- x * 4 y <- x + 4 plot(x, y, cex = z, col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ############################## x <- seq(1:100)/10 y <- x * 4 z <- x + 4 plot(jitter(x), jitter(z), cex = jitter(y), col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ############################## x <- seq(1:100)/10 y <- x * 4 + rnorm(100) z <- x + 4 + rnorm(100) plot(x, z, cex = y, col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ############################# x <- rnorm(100, 5, 1) y <- x + 2 z <- x + 4 plot(x, z, cex = y, col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ######################################## x <- rnorm(100, 5, 1) y <- x^2 z <- 5 + x plot(x, z, cex = y, col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ######################################## x <- rnorm(100, 5, 1) y <- (x/2)^2 z <- 5 + x plot(x, z, cex = y, col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ######################################### x <- rnorm(100, 10, 1.5) y <- .95*x z <- 5 + .9*x + .9*y #+ rnorm(100, 0, 1) plot(x, z, cex = y, col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ######################################### x <- rbinom(100, 5, .5) y <- .95*x + rbinom(100, 5, .5) z <- 5 + .9*x + .9*y + rnorm(100, 0, 1) plot(x, z, cex = y, col = "blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ######################################### x <- rbinom(100, 5, .2) y <- rbinom(100, 5, .5) + .9*x z <- rbinom(100, 5, .5) + .9*x + .9*y plot(x, y, cex = z, col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- rbinom(100, 5, .5) y <- x + c(rep(1, 20), rep(2, 20), rep(3, 20), rep(4, 20), rep(5, 20)) z <- x + y + rbinom(100, 5, .5) plot(x, z, cex = y, col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- (seq(1:100)/10) z <- (x^3) y <- (x^2 + 5) plot(x, y, cex = z, col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- (seq(1:100)/10) z <- (x^3) y <- (x^2 + 5)*-1 plot(x, y, cex = z, col="blue") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) bill <- data.frame(x,y) plot(bill, col = "blue", xlab="x", ylab="y") lines(lowess(bill, f=.2), lwd=3, col="green") ####################################### x <- (seq(1:100)/10) z <- (x^2) y <- (x^2 + 5) plot(x, y, cex = z, col="red") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- (seq(1:100)/10) z <- (x^2) y <- ((x - 1)^2 + 5) plot(x, y, cex = z, col="purple") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob) ####################################### x <- (seq(1:100)/10) z <- (x^3) y <- ((x - 1)^2 + 5) plot(x, y, cex = z, col="cyan") bob <- data.frame(x, y, z) summary(bob) cor(bob) pairs(bob)