Problem 1:
Swearing, the use of offensive or obscene language occurs, in most
human cultures. People swear to let off steam, to shock or insult, or
out of habit. Cathartic swearing may occur in painful situations, for
example, giving birth or hitting one’s thumb with a hammer. To test
whether swearing increases one’s tolerance for pain the following
experiment was conducted. Twenty college-aged men were recruited for the
study. At the outset they were informed that the study was concerned
with quantifying the degree of stress that various forms of language
elicit during tense situations. Participants submerged their
non-dominant hand in room temperature water for three minutes and then
immersed the same hand in 5◦C water with the instruction that they
should submerge their unclenched hand for as long as possible while
repeating a common word, for example, “chair” or a swear word of their
choice. The order of the two trials was determined by a coin flip. The
data for these 20 participants with durations in 5◦C water recorded in
seconds is contained in the csv file (HW3).
a) Conduct a paired t-test on the data. Report the
P value and the confidence interval for the mean of the difference
column. Explain results.
test <- t.test(swears$Swearing,
swears$`Not Swearing`,
paired = TRUE)
test
##
## Paired t-test
##
## data: swears$Swearing and swears$`Not Swearing`
## t = 4.0503, df = 19, p-value = 0.000683
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 15.24641 47.85359
## sample estimates:
## mean of the differences
## 31.55
p-value = 0.000683 < 0.05
Confidence Interval= (15.24641, 47.85359)
Null Hypothesis: the mean of the hypothetical difference column = 0
(we didn’t actually make a difference column). In other words, there is
no difference between the two treatments (swearing vs not swearing)
Because the p-value < 0.05, we reject the null hypothesis that
there is no mean difference between the treatments. The confidence
interval further supports that there is a significant difference between
treatment means because it does not contain 0; we are 95% confident that
swearing, on average, makes a difference in pain tolerance.
b) Do a correlation analysis to assess how
effective is the pairing (see page 311 in the book). Explain the
results.
cor <-cor.test(swears$Swearing,
swears$`Not Swearing`,
method=c("pearson"))
cor
##
## Pearson's product-moment correlation
##
## data: swears$Swearing and swears$`Not Swearing`
## t = 7.1716, df = 18, p-value = 1.121e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.6753765 0.9437502
## sample estimates:
## cor
## 0.8606703
Confidence Interval = (0.6753765 0.9437502)
correlation coefficient(r) = 0.8606703
coefficient of determination (r^2) = 0.740753365
p-value = 1.121e-06
The correlation coefficient (r) is positive but <1, so the two
values are positively correlated but scattered. The coefficient of
determination, r^2 = 0.74, meaning that 74% of the variability can be
explained by swearing or not swearing during the ice water test. The
remaining 26% would be explained by unrelated outside factors or errors.
This correlation is fairly strong and shows us that the pairing is
effective, especially since the paired p-value (part a) is much smaller
than the unpaired p-value (part c). Additionally, the p-value for r is
< 0.05 to further support this.
c) Conduct an unpaired t-test (yes! again) with the
same dataset assuming two independent samples with equal variance.
Report the P value and the confidence interval for the difference
between means. Compare the results with part “a.”
sweartest <- t.test(swears$Swearing,
swears$`Not Swearing`,
paired = FALSE, var.equal = TRUE)
sweartest
##
## Two Sample t-test
##
## data: swears$Swearing and swears$`Not Swearing`
## t = 1.7034, df = 38, p-value = 0.09667
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -5.946296 69.046296
## sample estimates:
## mean of x mean of y
## 195.95 164.40
p value = 0.09667 > 0.05
confidence interval = ( -5.946296 69.046296)
Null Hypothesis: There is no significant difference between the
means two treatment groups.
Given a p-value >0.05 and confidence intervals that include 0, we
cannot reject the null hypothesis– there is no significant difference
between the two treatment means. In this case, it was worth it to do a
paired t-test (part a) in order to preserve statistical power because
the correlation analysis showed a strong positive relationship between
swearing and not swearing treatments. This makes sense, because the
experimental design was established as paired–each individual
participated in both the swearing and not swearing treatment.
d) Conduct a linear regression analysis equivalent
to the unpaired t-test (see page 361 in the book). Report the slope with
its confidence interval, and the P value based on the F ratio test.
Explain the results. NOTE: the p-value should be identical to the one
obtained in part “c.”
binaryswears <- read_excel("~/Documents/Biometry/binaryswearsHW3.xlsx")
swear_regression <- lm (Time ~ Swearornot, data=binaryswears)
summary(swear_regression)
##
## Call:
## lm(formula = Time ~ Swearornot, data = binaryswears)
##
## Residuals:
## Min 1Q Median 3Q Max
## -118.95 -45.20 9.55 43.55 95.05
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 164.40 13.10 12.552 4.32e-15 ***
## Swearornot 31.55 18.52 1.703 0.0967 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 58.57 on 38 degrees of freedom
## Multiple R-squared: 0.07094, Adjusted R-squared: 0.04649
## F-statistic: 2.901 on 1 and 38 DF, p-value: 0.09667
confint(swear_regression, 'Swearornot', level = 0.95)
## 2.5 % 97.5 %
## Swearornot -5.946296 69.0463
Slope = 31.55, CI of slope = (-5.946296 69.0463) Intercept =
164.4
p-value = 0.09667
Null hypothesis: There is no linear relationship between swearing
and not swearing treatments.
The slope represents the difference between the means still, because
we are working with binary data (swearing = 1, no swearing = 0).The
p-value for the slope > 0.05 and confidence intervals do contain 0,
so we cannot reject the null hypothesis. This does necessarily mean that
there is NO relationship between swearing and not swearing, simply that
the relationship, if it exists, is not linear. Because the p-value
(=0.09667) for the F-ratio > 0.05, we cannot reject the null that the
relationshi between the two treatments are a straight line (no
difference between treatment means)