## linear regression demonstration ## ADM 10/21/2007 ## load the real civil liberties data load("civlib.Rda") ## create the scatterplot plot(civlib$ideology, civlib$civlib, xlab="Ideology", ylab="% Liberal in Civil Liberties Cases") ## find the "best" regression line results <- lm(civlib$civlib~civlib$ideology) print(results) ## we can use this to put the line on the scatterplot abline(results, lwd=3, col="red") ## we can summarize the linear model object print(summary(results)) ## let's fit a multiple regression model load("state2.Rda") results2 <- lm(turnout~hsdip+unemp, data=state2) print(results2) print(summary(results2))