--- title: "CAFE" author: "Chris Parrish" date: "January 24, 2016" output: pdf_document --- CAFE references: - Cannon, et al., Stat2, chapter 09, example 10.1 - Cannon, et al., Student R Manual, chapter 10 Import the data. ```{r} data <- read.csv("CAFE.csv", header=TRUE) head(data) dim(data) ``` View the data. ```{r} library(lattice) xyplot(Contribution ~ Party, data=data) ``` Remove Independent Senator. ```{r} x <- with(data, Party[!Party == "I"]) y <- with(data, Contribution[Party != "I"]) xyplot(y ~ x) ``` Somewhat different illustrations of the same data. ```{r} plot(jitter(as.numeric(x), amount=.05), y, xlab='Party', ylab='Contribution', xaxt="n", col="steelblue") axis(1, 1:3, labels=c("Dem", "", "Rep"), tck=0) ``` Dotplot. ```{r fig.width=6, fig.height=3.0} dem <- with(data, Contribution[Party == "D"]) rep <- with(data, Contribution[Party == "R"]) stripchart(list(dem, rep), ylim=c(1, 2), at=c(1.1, 1.65), pch=20, col="darkred", method="stack", group.names=c("Dem", "Rep"), xlab="Contribution") ``` glm. ```{r} CAFE.glm <- glm(Vote ~ log(1+Contribution) + Dem, data=data, family=binomial) options(show.signif.stars=FALSE) summary(CAFE.glm) ``` Interaction? ```{r} CAFE.glm2 <- glm(Vote ~ LogContr*Dem, data=data, family=binomial) summary(CAFE.glm2) ``` CI using "profile likelihood" rather than Wald z-statistic ```{r} confint(CAFE.glm) ```