setwd('C:/local/classes/M588') ##25 data <- read.csv("el2000.csv", header = TRUE) attach(data) names(data) lbuchanan <- log(buchanan2000[county != 'PALM BEACH']) lbush <- log(bush2000[county != 'PALM BEACH']) # log-log, indicating a power model, seems the best lm1 <- lm(lbuchanan ~ lbush) plot(lbush, lbuchanan) abline(lm1$coef[1], lm1$coef[2]) summary(lm1) ## though it is strange that the power is not 1! palmbeach <- data.frame(lbush = log(bush2000[county == 'PALM BEACH'] )) exp(predict(lm1,palmbeach , interval = 'prediction')) ## with 95% confidence, Buchanan would have expected to get between 592 and 1399 votes in Palm Beach (misGore <- buchanan2000[county == 'PALM BEACH'] - 1399 ) ## Obama????