knitr::opts_chunk$set(echo = TRUE)
require(Sleuth3)
require(tigerstats)
spock <- transform(case0502, Judge = factor(Judge, levels = c("Spock's", "A", "B", "C", "D", "E", "F")))
In this dataset, we have the percentage of women on venires for different judges, including a judge who presided over the trial of Benjamin Spock. We are interested to know whether Spock’s judge had fewer women in his venires than other judges.
Here’s a boxplot
bwplot(Percent ~ Judge, data = spock)
Here’s the t-test:
notspock <- subset(spock, Judge != "Spock's")
onlyspock <- subset(spock, Judge == "Spock's")
t.test(notspock$Percent, onlyspock$Percent, var.equal=TRUE)
##
## Two Sample t-test
##
## data: notspock$Percent and onlyspock$Percent
## t = 5.6697, df = 44, p-value = 1.03e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 9.584045 20.155294
## sample estimates:
## mean of x mean of y
## 29.49189 14.62222
Now, let’s run ANOVA with just the indicator variable for Spock’s trial as an indicator.
spock$SPOCKJUDGE <- spock$Judge == "Spock's"
anova(lm(Percent~SPOCKJUDGE, data=spock))
## Analysis of Variance Table
##
## Response: Percent
## Df Sum Sq Mean Sq F value Pr(>F)
## SPOCKJUDGE 1 1600.6 1600.62 32.145 1.03e-06 ***
## Residuals 44 2190.9 49.79
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1