install.packages("gdata")
Installing package into ‘/Users/jaclynbazsika/Library/R/3.3/library’
(as ‘lib’ is unspecified)
also installing the dependency ‘gtools’
trying URL 'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/gtools_3.5.0.tgz'
Content type 'application/x-gzip' length 134356 bytes (131 KB)
==================================================
downloaded 131 KB
trying URL 'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/gdata_2.17.0.tgz'
Content type 'application/x-gzip' length 1136842 bytes (1.1 MB)
==================================================
downloaded 1.1 MB
The downloaded binary packages are in
/var/folders/8s/6xnh03sd7zzc1nny5h0xzx3h0000gn/T//RtmpoRfMSo/downloaded_packages
library(gdata)
gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
Attaching package: ‘gdata’
The following object is masked from ‘package:stats’:
nobs
The following object is masked from ‘package:utils’:
object.size
The following object is masked from ‘package:base’:
startsWith
my.data = read.xls("/Users/jaclynbazsika/Documents/paired t-test_3.xlsx")
my.data
In the following experiment, the data depicts the results of a study taken by 12 random individuals. It shows thier blood pressure taken before and after a non-interventional study for XYZ and ABC drug. The purpose was to determine whether the drugs had a positive, negative or nuetral effect on the participants. A positive effect would mean that the drug lowered BP. A negative effect would mean it did not lower BP.
Start_BP= c(155,142,145,160,149,152,157,159,166,163,158,161)
XYZ_BP= c(152,142,144,159,150,153,156,160,165,162,159,160)
t.test(Start_BP,XYZ_BP,paired = TRUE)
Paired t-test
data: Start_BP and XYZ_BP
t = 1.1639, df = 11, p-value = 0.2691
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.3712632 1.2045965
sample estimates:
mean of the differences
0.4166667
In this paired, one-sided t-test, we compared the starting blood pressure of the XYZ drug group. This paired t-test examines whether there is a difference in the starting BP vs. the BP after the drug was administered. Given the data, the results do not indicate a significant difference in results. Therefore, we can accept the nullhypothesis, in that there is little to no difference between the two variables. The P-value is greater than 0.05.
Start_BP= c(155,142,145,160,149,152,157,159,166,163,158,161)
XYZ_BP= c(152,142,144,159,150,153,156,160,165,162,159,160)
t.test(Start_BP,XYZ_BP,paired = TRUE, alt="less")
Paired t-test
data: Start_BP and XYZ_BP
t = 1.1639, df = 11, p-value = 0.8655
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
-Inf 1.059575
sample estimates:
mean of the differences
0.4166667
In this paired, two-sided t-test, we hypothesized that the Start_BP was less than the XYZ_BP. We are rejecting the null, but accepting the alternative because the starting BP is greater XYZ BP. Therefore, we have a p-value of 0.8655, which is higher than 0.05.
Start_BP= c(155,142,145,160,149,152,157,159,166,163,158,161)
XYZ_BP= c(152,142,144,159,150,153,156,160,165,162,159,160)
t.test(Start_BP,XYZ_BP,paired = TRUE, alt="greater")
Paired t-test
data: Start_BP and XYZ_BP
t = 1.1639, df = 11, p-value = 0.1345
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
-0.2262415 Inf
sample estimates:
mean of the differences
0.4166667
Here, we did a two-sided, paired t-test. Our alternative hypothesis states that the intital BP. Given the sample set, we are able to see that the starting BP was in fact higher than the BP taken at the end of the drug trial. We therefore can accept the null, since the p-value is greater than 0.05.
#load data ABC trial
ABC_trial= c(150,135,142,153,142,147,152,149,158,155,150,150)
#one-sided t-test
Start_BP= c(155,142,145,160,149,152,157,159,166,163,158,161)
ABC_trial= c(150,135,142,153,142,147,152,149,158,155,150,150)
t.test(Start_BP,ABC_trial,paired = TRUE)
Here, we shift gears and do another paired, one-sided t-test.We wanted to see if there was a difference between the starting BP of XYZ and the ABC trial. Given the sample set, we can tell that there is in fact a difference between the two groups, and a p-value of 3.582e-07 therefore, we reject the null hypothesis.
Start_BP= c(155,142,145,160,149,152,157,159,166,163,158,161)
ABC_trial= c(150,135,142,153,142,147,152,149,158,155,150,150)
t.test(Start_BP,ABC_trial,paired = TRUE, alt="greater")
In this test, we evaluated whether the Start_BP was greater compared to the ABC trial. We were able to reject the null hypothesis, given the p-value 1.791e-07, and accept the alternative hypothesis, which suggests that the BP for XYZ is higher than ABC.
t.test(ABC_trial,Start_BP, paired = TRUE, alt="less")
Paired t-test
data: ABC_trial and Start_BP
t = -10.747, df = 11, p-value = 1.791e-07
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
-Inf -5.83027
sample estimates:
mean of the differences
-7
hist(Start_BP)
hist(XYZ_BP)
hist(ABC_trial)
In the final test, we hypothesized that the BP in ABC_trial was lower than Start_BP. We rejected the null hypothesis given the p-value 1.791e-07, and accepted the alternative hypothesis, in that the BP was in fact lower at te conclusion of ABC trial.
We can ascertain that the drug trial did have a positive effect on participants. Data from the intial BP reading shows that BP was higher compared to the final reading from each drug trial. There were no known negative relationships in either experiments. Starting with XYZ, we were able to see that the drug has a stastically significant effect on the sample group; However, if we were to determine which drug was more effective, then it would be ABC. ABC drug was the only drug where we were able to reject the null, and accept the alternative hypothesis, and see a positive effect on the participants. With XYZ, we accepted the null, and the alternative hypothesis. there just wasn’t a significant difference between the means to reject the null hypothesis.
Since we used the same group, we were able to recieve consistent results. We saw a normal distribution with each sample. Our P-values indicate that in cases where we hypothesized that the final BP reading was less than the inital reading, we had a lower value; However, when we stated that the intial BP was in fact lower than the final BP for both drug trials, we saw a higher p-value.