alpha= 0.05
\(h_o\)= \(u_1\) - \(u_2\) = 0
\(h_a\)= \(u_1\) != \(u_2\)
dat <- read.csv(file.choose())
t.test(dat$A,dat$B,paired=TRUE)
##
## Paired t-test
##
## data: dat$A and dat$B
## t = 3.6742, df = 9, p-value = 0.005121
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.383548 5.816452
## sample estimates:
## mean of the differences
## 3.6
The p.value 0.005121 is less than alpha, so We have enough evidence to reject Ho. The aspirine A has a different effect than aspirine B.
t.test(dat$A,dat$B,var.equal = TRUE)
##
## Two Sample t-test
##
## data: dat$A and dat$B
## t = 0.9802, df = 18, p-value = 0.34
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.116103 11.316103
## sample estimates:
## mean of x mean of y
## 19.2 15.6
The p.value 0.34 is greater than alpha, so We dont have enough evidence to reject Ho. The aspirine A has the same effect than aspirine B.
dat2<- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv",na.strings = "")
males<- dat2 %>% filter(Sex == 1)
females <- dat2 %>% filter(Sex == 2)
boxplot(males$ï..Temp,females$ï..Temp, main="Resting temparatures", names=c("Males","Females"),ylab = "Temperature")
The variances don´t seem to be constant because the median are different and the range is wider for the males.
\(H_0\) = \(u_1\) - \(u_2\) = 0
\(H_a\) = \(u_1\) ≠ \(u_2\)
t.test(males$ï..Temp,females$ï..Temp,var.equal = TRUE)
##
## Two Sample t-test
##
## data: males$ï..Temp and females$ï..Temp
## t = -2.2854, df = 128, p-value = 0.02393
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.53963938 -0.03882216
## sample estimates:
## mean of x mean of y
## 98.10462 98.39385
t.test(males$ï..Temp,females$ï..Temp,var.equal = FALSE)
##
## Welch Two Sample t-test
##
## data: males$ï..Temp and females$ï..Temp
## t = -2.2854, df = 127.51, p-value = 0.02394
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.53964856 -0.03881298
## sample estimates:
## mean of x mean of y
## 98.10462 98.39385
As we can see, the p values for both tests are almost equal. Therefore, the variances appear to be constant. In addition, as the p value is less than alpha, we have enough evidence to reject H0. Hence, the resting temperatures appear to be different for males and females
library(dplyr)
dat <- read.csv(file.choose())
qqnorm(dat$A)
qqnorm(dat$B)
t.test(dat$A,dat$B,paired=TRUE)
t.test(dat$A,dat$B,var.equal = TRUE)
dat2<- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/normtemp.csv",na.strings = "")
males<- dat2 %>% filter(Sex == 1)
females <- dat2 %>% filter(Sex == 2)
boxplot(males$ï..Temp,females$ï..Temp, main="Resting temparatures", names=c("Males","Females"),ylab = "Temperature")
t.test(males$ï..Temp,females$ï..Temp,var.equal = TRUE)
t.test(males$ï..Temp,females$ï..Temp,var.equal = FALSE)