hrdata <- read.csv("HR-Employee-Attrition.csv")

cor(
hrdata[ , c("Age", "DailyRate", "DistanceFromHome", "Education", "HourlyRate", "MonthlyIncome", "MonthlyRate", "NumCompaniesWorked", "TotalWorkingYears", "TrainingTimesLastYear")]
)
##                               Age    DailyRate DistanceFromHome   Education
## Age                    1.00000000  0.010660943     -0.001686120  0.20803373
## DailyRate              0.01066094  1.000000000     -0.004985337 -0.01680643
## DistanceFromHome      -0.00168612 -0.004985337      1.000000000  0.02104183
## Education              0.20803373 -0.016806433      0.021041826  1.00000000
## HourlyRate             0.02428654  0.023381422      0.031130586  0.01677483
## MonthlyIncome          0.49785457  0.007707059     -0.017014445  0.09496068
## MonthlyRate            0.02805117 -0.032181602      0.027472864 -0.02608420
## NumCompaniesWorked     0.29963476  0.038153434     -0.029250804  0.12631656
## TotalWorkingYears      0.68038054  0.014514739      0.004628426  0.14827970
## TrainingTimesLastYear -0.01962082  0.002452543     -0.036942234 -0.02510024
##                         HourlyRate MonthlyIncome  MonthlyRate
## Age                    0.024286543   0.497854567  0.028051167
## DailyRate              0.023381422   0.007707059 -0.032181602
## DistanceFromHome       0.031130586  -0.017014445  0.027472864
## Education              0.016774829   0.094960677 -0.026084197
## HourlyRate             1.000000000  -0.015794304 -0.015296750
## MonthlyIncome         -0.015794304   1.000000000  0.034813626
## MonthlyRate           -0.015296750   0.034813626  1.000000000
## NumCompaniesWorked     0.022156883   0.149515216  0.017521353
## TotalWorkingYears     -0.002333682   0.772893246  0.026442471
## TrainingTimesLastYear -0.008547685  -0.021736277  0.001466881
##                       NumCompaniesWorked TotalWorkingYears
## Age                           0.29963476       0.680380536
## DailyRate                     0.03815343       0.014514739
## DistanceFromHome             -0.02925080       0.004628426
## Education                     0.12631656       0.148279697
## HourlyRate                    0.02215688      -0.002333682
## MonthlyIncome                 0.14951522       0.772893246
## MonthlyRate                   0.01752135       0.026442471
## NumCompaniesWorked            1.00000000       0.237638590
## TotalWorkingYears             0.23763859       1.000000000
## TrainingTimesLastYear        -0.06605407      -0.035661571
##                       TrainingTimesLastYear
## Age                            -0.019620819
## DailyRate                       0.002452543
## DistanceFromHome               -0.036942234
## Education                      -0.025100241
## HourlyRate                     -0.008547685
## MonthlyIncome                  -0.021736277
## MonthlyRate                     0.001466881
## NumCompaniesWorked             -0.066054072
## TotalWorkingYears              -0.035661571
## TrainingTimesLastYear           1.000000000
pairs(~MonthlyIncome+Age+TotalWorkingYears+Education,data = hrdata,
main = "Scatterplot Matrix")

yes_age <- hrdata[(hrdata$Attrition=="Yes"),'Age']
no_age <- hrdata[(hrdata$Attrition=="No"),'Age']

t.test(yes_age, no_age)
## 
##  Welch Two Sample t-test
## 
## data:  yes_age and no_age
## t = -5.828, df = 316.93, p-value = 1.38e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -5.288346 -2.618930
## sample estimates:
## mean of x mean of y 
##  33.60759  37.56123
boxplot(EmployeeNumber~Attrition,data=hrdata, main="Who Got Fired", xlab="Attrition", ylab="EmployeeNumber")

yes_number <- hrdata[(hrdata$Attrition == "Yes"), 'EmployeeNumber']
no_number <- hrdata[(hrdata$Attrition =="No"), 'EmployeeNumber']
t.test(yes_number,no_number)
## 
##  Welch Two Sample t-test
## 
## data:  yes_number and no_number
## t = -0.41725, df = 342.33, p-value = 0.6768
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -98.91087  64.29061
## sample estimates:
## mean of x mean of y 
##  1010.346  1027.656
model1 = lm(MonthlyIncome ~ Age, data = hrdata)
summary(model1)
## 
## Call:
## lm(formula = MonthlyIncome ~ Age, data = hrdata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9990.1 -2592.7  -677.9  1810.5 12540.8 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -2970.67     443.70  -6.695 3.06e-11 ***
## Age           256.57      11.67  21.995  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4084 on 1468 degrees of freedom
## Multiple R-squared:  0.2479, Adjusted R-squared:  0.2473 
## F-statistic: 483.8 on 1 and 1468 DF,  p-value: < 2.2e-16
model2 = lm(MonthlyIncome ~ Age + TotalWorkingYears, data = hrdata)
summary(model2)
## 
## Call:
## lm(formula = MonthlyIncome ~ Age + TotalWorkingYears, data = hrdata)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11310.8  -1690.8    -91.4   1428.3  11461.5 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        1978.08     352.36   5.614 2.36e-08 ***
## Age                 -26.87      11.63  -2.311    0.021 *  
## TotalWorkingYears   489.13      13.65  35.824  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2984 on 1467 degrees of freedom
## Multiple R-squared:  0.5988, Adjusted R-squared:  0.5983 
## F-statistic:  1095 on 2 and 1467 DF,  p-value: < 2.2e-16