# Example 2.5, Voting Outcomes and Campaign Expenditures
# Data set: vote1
load("vote1.Rdata")
# Describe the model and summarize the variables
cat("The data set contains data on election outcomes and campaign expenditures for 173 two-party races for the U.S. House of Representatives in 1988. There are two candidates in each race, A and B.")
cat("Model to estimate: voteA = beta0 + beta1 * shareA + u",
"\n where voteA is", paste(desc[desc[,1]=="voteA",2]),
"\n and shareA is", paste(desc[desc[,1]=="shareA",2]))
summary(data$voteA)
summary(data$shareA)
# Estimate and show results
model=lm(voteA~shareA, data=data)
summary(model)
cat("The estimated regression line is\n",
"voteAhat =", round(model$coefficients[1],digits=2), "+",
round(model$coefficients[2],digits=3), "* shareA\n",
"n =", nrow(data))
# Interpretation
cat("When shareA increases by 1 percentage point, voteA is predicted to increase by",
round(model$coefficients[2],digits=3), "percentage point\n",
"When shareA = 50, voteA is predicted to be", round(model$coefficients[1],digits=2),
"+", round(model$coefficients[2],digits=3), "* 50 =",
round(model$coefficients[1]+model$coefficients[2]*50, digits=2), ", or one half")