######################################## # # Script: 31 March 2011 (preliminary) # ######################################## # Today: # # ** Miscellaneous helpful items # crime <- read.csv("http://courses.kvasaheim.com/stat40x3/data/crime.csv", header=TRUE) names(crime) summary(crime) m0 <- glm( gspcap00 ~ gspcap90 * vcrime90, family=gaussian(link=identity), data=crime ) summary(m0) m1 <- glm( gspcap00 ~ gspcap90 + vcrime90, family=gaussian(link=identity), data=crime ) summary(m1) # Functions in the y-variable m2 <- glm( I(gspcap00-gspcap90) ~ vcrime90, family=gaussian(link=identity), data=crime ) summary(m2) # The with() function with( crime, cor(vcrime90, vcrime00) ) # The indentify() function plot( I(vcrime00-vcrime90)~gspcap90, data=crime) abline(h=0) with(crime, identify( gspcap90, I(vcrime00-vcrime90), n=10, pos=T, labels=scode) ) # The text() function plot( I(vcrime00-vcrime90)~gspcap90, data=crime, type="n") with(crime, text( I(vcrime00-vcrime90)~gspcap90, labels=scode) )