This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
data=read.csv("finance_data.csv",header = T)
data$Education.Level[which(data$Education.Level=="Bachelor's Degree")]="Bachelor's"
data$Education.Level=factor(data$Education.Level)
data$Gender=factor(data$Gender)
data$Job.Title=factor(data$Job.Title)
summary(data)
## Age Gender Education.Level Job.Title
## Min. :24.00 Female:109 Bachelor's :103 Account Manager : 1
## 1st Qu.:30.00 Male : 69 High School: 5 Accountant : 1
## Median :31.00 Master's : 67 Director of Finance: 2
## Mean :33.77 PhD : 3 Financial Advisor : 1
## 3rd Qu.:39.00 Financial Analyst : 39
## Max. :50.00 Financial Manager :134
## Years.of.Experience Salary
## Min. : 1.000 Min. : 45000
## 1st Qu.: 5.000 1st Qu.: 90000
## Median : 7.500 Median :120000
## Mean : 9.399 Mean :130140
## 3rd Qu.:16.000 3rd Qu.:200000
## Max. :21.000 Max. :250000
aov=aov(data$Salary~data$Gender+data$Education.Level+data$Gender:data$Education.Level)
summary(aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## data$Gender 1 9.417e+10 9.417e+10 40.548 1.71e-09 ***
## data$Education.Level 3 4.526e+10 1.509e+10 6.497 0.000345 ***
## data$Gender:data$Education.Level 2 3.798e+10 1.899e+10 8.176 0.000406 ***
## Residuals 171 3.971e+11 2.322e+09
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
fit1=lm(Salary~Age+Gender+Education.Level,data=data)
summary(fit1)
##
## Call:
## lm(formula = Salary ~ Age + Gender + Education.Level, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -98407 -9025 8649 22457 37567
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -146117.3 17673.9 -8.267 3.58e-14 ***
## Age 8299.0 477.8 17.369 < 2e-16 ***
## GenderMale -14903.3 5233.8 -2.848 0.00494 **
## Education.LevelHigh School -21332.8 14383.3 -1.483 0.13986
## Education.LevelMaster's 9575.2 5265.1 1.819 0.07071 .
## Education.LevelPhD -72611.7 17798.2 -4.080 6.89e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 30310 on 172 degrees of freedom
## Multiple R-squared: 0.725, Adjusted R-squared: 0.717
## F-statistic: 90.7 on 5 and 172 DF, p-value: < 2.2e-16
library(asbio)
## 載入需要的套件:tcltk
bonfCI(data$Salary,data$Education.Level)
##
## 95% Bonferroni confidence intervals
##
## Diff Lower Upper Decision
## muBachelor's-muHigh School 94097.08738 28622.66973 159571.50503 Reject H0
## muBachelor's-muMaster's 30171.71424 7731.25047 52612.17802 Reject H0
## muHigh School-muMaster's -63925.37313 -130209.14682 2358.40056 FTR H0
## muBachelor's-muPhD 56763.75405 -26977.03989 140504.54798 FTR H0
## muHigh School-muPhD -37333.33333 -141748.29782 67081.63116 FTR H0
## muMaster's-muPhD 26592.0398 -57783.07417 110967.15377 FTR H0
## Adj. p-value
## muBachelor's-muHigh School 0.00105
## muBachelor's-muMaster's 0.002596
## muHigh School-muMaster's 0.065351
## muBachelor's-muPhD 0.433045
## muHigh School-muPhD 1
## muMaster's-muPhD 1
bonfCI(data$Salary,data$Gender)
##
## 95% Bonferroni confidence intervals
##
## Diff Lower Upper Decision Adj. p-value
## muFemale-muMale 47208.48291 31347.07268 63069.89315 Reject H0 0