Last updated: 07:55:36 IST, 24 August, 2023
A services company has its employees in Bangalore and Mumbai. They would like to compare salaries of employees (with the same skill) in these two cities to decide if they should offer different salaries at recruitment time or during annual salary revisions.
For this, an agency did a survey of about 200 employees (with the skill) across companies in each of these two locations.
Sample size is large (n1 = 200; n2 = 210)
Population mean and variance is unknown
Ho: Population means mu1 = mu2
Ha: Population means mu1 \(\neq\) mu2
Two Sample two sided t-test will be used with alternative hypothesis as ‘two.sided’
# Create a data sample of size 200,
# for Bangalore from a population with a mean annual salary of 10 LPA and a standard deviation of 0.2 LPA.
blore_saldata <- rnorm(200,mean=10,sd=0.2)
# Create a data sample of size 210,
# for Mumbai from a population with a mean annual salary of 12 LPA and a standard deviation of 0.2 LPA.
mumbai_saldata <- rnorm(210,mean=12,sd=0.2)
# View the summary of the data sample
summary(blore_saldata)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 9.529 9.865 10.011 10.009 10.121 10.545
sd(blore_saldata)
## [1] 0.1955332
summary(mumbai_saldata)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 11.49 11.85 11.98 11.98 12.10 12.43
sd(mumbai_saldata)
## [1] 0.1825458
# Two-sample, Two-sided t-Test.
ttest_res <- t.test(blore_saldata,mumbai_saldata, alternative = 'two.sided')
ttest_res
##
## Welch Two Sample t-test
##
## data: blore_saldata and mumbai_saldata
## t = -105.48, df = 402.45, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -2.009738 -1.936198
## sample estimates:
## mean of x mean of y
## 10.00926 11.98223
# Create a data sample of size 200,
# for Bangalore from a population with a mean annual salary of 11.8 LPA and a standard deviation of 0.2 LPA.
blore_saldata <- rnorm(200,mean=11.8,sd=0.2)
# Create a data sample of size 210,
# for Mumbai from a population with a mean annual salary of 12 LPA and a standard deviation of 0.2 LPA.
mumbai_saldata <- rnorm(210,mean=12,sd=0.2)
# View the summary of the data sample
summary(blore_saldata)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 11.25 11.64 11.81 11.79 11.93 12.23
sd(blore_saldata)
## [1] 0.2064398
summary(mumbai_saldata)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 11.34 11.82 11.98 11.98 12.13 12.55
sd(mumbai_saldata)
## [1] 0.2072001
# Two-sample, Two-sided t-Test.
ttest_res <- t.test(blore_saldata,mumbai_saldata, alternative = 'two.sided')
ttest_res
##
## Welch Two Sample t-test
##
## data: blore_saldata and mumbai_saldata
## t = -9.1497, df = 407.17, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.2271273 -0.1467910
## sample estimates:
## mean of x mean of y
## 11.79263 11.97959