R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com. When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Question A

“7.2.14 Suppose we have conducted a t test, with α=0.05, and the p-value is 0.03. For each of the following statements, say whether the statement is true or false and explain why. (a) We reject H0 with α=0.05. (b) We have significant evidence for HA with α=0.05. (c) We would reject H0 if α were 0.10. (d) We do not have significant evidence for HA with α=0.10. (e) If H0 is true, the probability of getting a test statistic at least as extreme as the value of the t_s that was actually obtained is 3%. (f) There is a 3% probability that H0 is true.”

#(a) TRUE: α represents the significance level of the hypothesis test and it is predetermined. Because the P-value is less than α (0.03 < 0.05), then we reject the null hypothesis at a significance level of 0.05. This is because the chances for the outcome to be true have now been brought into question (thus the validity of the null hypothesis has been deemed suspicious). When the P-value is greater than α, then we fail to reject the null hypothesis.
#(b) TRUE: The P-value only gives us evidence for HA. a value of 0.05 for α simply denotes the cut-off line that we're creating to evaluate data on it's probability. Using these two pieces of informaiton, we can empirically come up with a conclusion founded on evidence to reject (or inability to reject) the null hypothesis. When the P-value is less than α, we reject the null hypothesis (which intrinsically supports HA).  
#(c) TRUE: When α = 0.10, we have simply shifted the evaluative parameters. Since the P-value is even smaller than α, compared to the previous examples, then it further supports the point of rejecting H0.
#(d) FALSE: as seen in (b), the P-value gives us information on the HA. Having a larger α while holding the p-value constant at (0.03) still states that the P-value is less than α. But now, we question the veracity of the results due to the hightened significance level (it is not as critical). 
#(e) FALSE: Whenever we obtain a 5% or lower from the t_s we are rejecting the null hypothesis.
#(f)FALSE: A probability of 3% does not support H0. It lacks the support due to the slim chances of it taking place.

Question B

“7.3.6 Suppose that a 95% confidence interval for (μ1 - μ2) is calculated to be (1.4, 6.7). If we test H0: μ1 - u2 = 0 versus HA: μ1 - μ2 ≠ 0 using α=0.05, will we reject H0? Why or why not?”

#We will reject the null hypothesis.
#This is because: the 95% CI interval (of the difference between mean 1 and mean 2) does not contain zero if and only if we reject the null hypothesis in favor of the alternate hypothesis at the 5% level. In this case, our significance level (α) is at the 0.05 level, and the CI 95% doesn't contain zero.

Question C

“8.S.20 (Computer exercise) In a study of hypnotic suggestion, 16 male volunteers were randomly allocated to an experimental group and a control group. Each subject participated in a two-phase experimental session. In the first phase, respiration was measured while the subject was awake and at rest. (These measurements were also described in Exercises 7.5.6 and 7.10.4.) In the second phase, the subject was told to imagine that he was performing muscular work, and respiration was measured again. For subjects in the experimental group, hypnosis was induced between the first and second phases; thus, the suggestion to imagine muscular work was “hypnotic suggestion” for control subjects. The accompany table shows the measurements of total ventilation (liters of air per minute per square meter of body area) for all 16 subjects. (a) Use a t test to compare the mean resting values in the two groups. Use a non-directional alternative and let α=0.05. This is the same as Exercise 7.5.6(a). (b) Use suitable paired and unpaired t test to investigate (i) the response of the experimental group to suggestion; (ii) the response of the control group to suggestion; (iii) the difference between the responses of the experimental and control groups. Use directional alternatives (suggestion increases ventilation, and hypnotic suggestion increases it more than waking suggestion) and let α=0.05 for each test. (c) Repeat the investigations of part (b) using suitable nonparametric tests (sign and Wilcoxon-Mann Whitney tests). (d) Using suitable graphs to investigate the reasonableness of the normality condition underlying the t tests of part (b). How does this investigation shed light on the discrepancies between the results of parts (b) and (c)?”

#(a) t-test to compare the mean resting values 
experimental_rest <- c(5.74, 6.79, 5.32, 7.18, 5.60, 6.06, 6.32, 6.34)
experimental_work <- c(6.24, 9.07, 7.77, 16.46, 6.95, 8.14, 11.72, 8.06)

control_rest <- c(6.21, 4.50, 4.86, 4.78, 4.79, 5.70, 5.41, 6.08)
control_work <- c(5.50, 4.64, 4.61, 3.78, 5.41, 5.32, 4.54, 5.98)

##Means and SDs of previous data + Histograms
mean_experimental_rest<-mean(experimental_rest)
std_experimental_rest<-sqrt(var(experimental_rest))

hist(experimental_rest, main = "Hypnotic Suggestion Experimental Rest", xlab= "air Liters/min/m^2 of body area", col = "blue", density = 20, breaks = 5, prob = TRUE)
curve(dnorm(x, mean=mean_experimental_rest, sd=std_experimental_rest), add=TRUE)

mean_experimental_work<-mean(experimental_work)
std_experimental_work<-sqrt(var(experimental_work))

hist(experimental_work, main = "Hypnotic Suggestion Experimental Work", xlab= "air Liters/min/m^2 of body area", col = "blue", density = 20, breaks = 5, prob = TRUE)
curve(dnorm(x, mean=mean_experimental_work, sd=std_experimental_work), add=TRUE)

mean_control_rest<-mean(control_rest)
std_control_rest<-sqrt(var(control_rest))

hist(control_rest, main = "Control Rest", xlab= "air Liters/min/m^2 of body area", col = "blue", density = 20, breaks = 5, prob = TRUE)
curve(dnorm(x, mean=mean_control_rest, sd=std_control_rest), add=TRUE)

mean_control_work<-mean(control_work)
std_control_work<-sqrt(var(control_work))

hist(control_work, main = "Control Work", xlab= "air Liters/min/m^2 of body area", col = "blue", density = 20, breaks = 5, prob = TRUE)
curve(dnorm(x, mean=mean_control_work, sd=std_control_work), add=TRUE)

#(b)Both paired and unpaired t-tests to explore 
##(i) the response of the experimental group to suggestion
###Paired
###p-value = 0.01742
t.test(experimental_rest, experimental_work, alternative = "two.sided", conf = 0.95, paired = TRUE)
## 
##  Paired t-test
## 
## data:  experimental_rest and experimental_work
## t = -3.0958, df = 7, p-value = 0.01742
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -5.5251677 -0.7398323
## sample estimates:
## mean of the differences 
##                 -3.1325
###Unpaired
###p-value = 0.03238
t.test(experimental_rest, experimental_work, alternative = "two.sided", conf = 0.95, paired = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  experimental_rest and experimental_work
## t = -2.6211, df = 7.4886, p-value = 0.03238
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -5.9215593 -0.3434407
## sample estimates:
## mean of x mean of y 
##   6.16875   9.30125
##(ii) the response of the control group to suggestion
###Paired
####p-value = 0.1412
t.test(control_rest, control_work, alternative = "two.sided", conf = 0.95, paired = TRUE)
## 
##  Paired t-test
## 
## data:  control_rest and control_work
## t = 1.6583, df = 7, p-value = 0.1412
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1357748  0.7732748
## sample estimates:
## mean of the differences 
##                 0.31875
###Unpaired
###p-value = 0.3629
t.test(control_rest, control_work, alternative = "two.sided", conf = 0.95, paired = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  control_rest and control_work
## t = 0.94077, df = 13.921, p-value = 0.3629
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.408328  1.045828
## sample estimates:
## mean of x mean of y 
##   5.29125   4.97250
#(iii) the difference between the responses of the experimental and control groups to suggestion
###Paired
###p-value = 0.01665
t.test(control_work, experimental_work, alternative = "two.sided", conf = 0.95, paired = TRUE)
## 
##  Paired t-test
## 
## data:  control_work and experimental_work
## t = -3.1281, df = 7, p-value = 0.01665
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7.60098 -1.05652
## sample estimates:
## mean of the differences 
##                -4.32875
###Unpaired
###p-value = 0.007513
t.test(control_work, experimental_work, alternative = "two.sided", conf = 0.95, paired = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  control_work and experimental_work
## t = -3.605, df = 7.6249, p-value = 0.007513
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7.121589 -1.535911
## sample estimates:
## mean of x mean of y 
##   4.97250   9.30125
#(c) Usign nonparametric tests repeat (b)
##(i) the response of the experimental group to suggestion
###p-value = 0.007813
wilcox.test(experimental_rest, experimental_work, paired = TRUE)
## 
##  Wilcoxon signed rank test
## 
## data:  experimental_rest and experimental_work
## V = 0, p-value = 0.007813
## alternative hypothesis: true location shift is not equal to 0
##Sign test
#When comparing the rest columns of both the experimental goup and the control group, 7 of the experimental subjects had greater measurements than those of the control group. Since these are different subjects, I considered increasing the trial number to 16 because each individual subject is independent from the next. But because I only made 8 comparisons, I'll keep the trail number at 8.
#p-value = 0.07031
binom.test(7, 8)
## 
##  Exact binomial test
## 
## data:  7 and 8
## number of successes = 7, number of trials = 8, p-value = 0.07031
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.4734903 0.9968403
## sample estimates:
## probability of success 
##                  0.875
##(ii) the response of the control group to suggestion
###p-value = 0.07422
wilcox.test(control_rest, control_work, paired = TRUE, alternative="greater")
## 
##  Wilcoxon signed rank test
## 
## data:  control_rest and control_work
## V = 29, p-value = 0.07422
## alternative hypothesis: true location shift is greater than 0
##Sign test
#When comparing the 2 columns of the control group, only 2 instances reflect an upward shift in liters of air/ min/ m^2 of body area. These were subject 10 and 13. I ascribed these instances as successes, and the trial number as the comparison between the two.
#p-value = 0.2891
binom.test(2, 8)
## 
##  Exact binomial test
## 
## data:  2 and 8
## number of successes = 2, number of trials = 8, p-value = 0.2891
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.03185403 0.65085579
## sample estimates:
## probability of success 
##                   0.25
#(iii) the difference between the responses of the experimental and control groups to suggestion
###p-value = 0.007813
wilcox.test(control_work, experimental_work, paired = TRUE)
## 
##  Wilcoxon signed rank test
## 
## data:  control_work and experimental_work
## V = 0, p-value = 0.007813
## alternative hypothesis: true location shift is not equal to 0
##Sign test
#When comparing the work columns of both the experimental goup and the control group. All of the experimental subjects showed higher measurements than the control group column. 
#p-value = 0.007812
binom.test(8, 8)
## 
##  Exact binomial test
## 
## data:  8 and 8
## number of successes = 8, number of trials = 8, p-value = 0.007812
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.6305834 1.0000000
## sample estimates:
## probability of success 
##                      1
#(d) graphs for normality condition of the t-tests in part (b). What are the discrepancies b/w (b) & (c)...
##The p-values change, even though the data that is analyzed is the same (when comparing (b-i) with (c-i), (b-ii) with (c-ii), (b-iii) with (c-iii). 
###(I) we use the two-sided t-test to compare central tendencies of two independent samples. 
###(II) we use the Wilcoxon Mann-Whitney test to compare central tendencies of two independent samples
###(III) we use the sign test to study the central tendency of a single sample.

####(I & II) the paired t test p-values are higher than the WMW test when comparing the resluts from (b) and (c). A p-value that rejects the null hypothesis with the MWM test, might fail to reject the null hypothesis in the paired t-test. (III) The sign test is focused on a single sample, but when comparing different individuals from different groups, this does not provide the most reliable data.