# Chapter 12 R examples, STAT 205 length = c(60,69,66,64,54,67,59,65,63) weight = c(136,198,194,140,93,172,116,174,145) plot(length, weight, pch=19, xlab="Length X (cm)",ylab="Weight Y(cm)") cor.test(length, weight, conf.level=0.95, alternative = “two.sided) length = c(60,69,66,64,54,67,59,65,63) weight = c(136,198,194,140,93,172,116,174,145) fit = lm(weight~length) summary(fit) plot(length, weight, xlab = "Length X (cm)", ylab = "Width Y (cm)") abline(fit) fit = lm(weight~length) summary(fit) confint(fit) # Logistic Regression example: tumorsize <- c(6.5,6.3,3.8,7.5,4.5,3.5,4.0,3.7,6.3,4.2,8.0,5.2,5.0,2.5,7.0,5.3,6.2,2.0,9.0,4.0,3.0,6.0,4.0,4.0,4.0,5.0,9.0,4.5,3.0,3.0,1.7) metastatis <- c(1,0,1,1,1,1,0,0,1,1,0,1,1,0,1,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0) fitlogist <- glm(metastatis~tumorsize, family="binomial") summary(fitlogist) # A plot of the data with the estimated logistic curve on top: plot(tumorsize, metastatis, pch=19) library(boot); xrange <- seq(from=min(tumorsize), to=max(tumorsize), length=100) lines(xrange, inv.logit(fitlogist$coef[1]+ fitlogist$coef[2]*xrange))