Module 8 unit7 post
Summary
I did the analysis using R - below is the R program used
R program
[Workspace loaded from ~/.RData]
library(readxl)
Exe_8_6C <- read_excel(“C:/Users/myounes/Downloads/Exe 8.6C.xlsx”)
View(Exe_8_6C)
library(readxl)
library(data.table)
data.table 1.15.2 using 4 threads (see ?getDTthreads). Latest news: r-datatable.com
Warning message:
package ‘data.table’ was built under R version 4.3.3
mydata = data.table(Exe_8_6C)
head(mydata)
Sex Income
1 M 40.6
2 M 54.6
3 M 38.6
4 M 58.2
5 M 34.6
6 M 42.9
sample1 = mydata[Sex==”M”]
sample2= mydata[Sex==”F”]
mean(sample1$Income) - mean(sample2$Income)
[1] 8.68
t.test(sample1$Income, sample2$Income, alternative = “two.sided”, var.equal = FALSE, conf.level = 0.95)
Welch Two Sample t-test
data: sample1$Income and sample2$Income
t = 3.2679, df = 116.8, p-value = 0.001423
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
3.419559 13.940441
sample estimates:
mean of x mean of y
52.91333 44.23333
Comments on the results
Since the p-value is very small (p < 0.05), we reject the null hypothesis. This provides strong evidence that the mean income for males is significantly higher than that of females.